forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssetPathVersionMetaData.cs
More file actions
75 lines (65 loc) · 2.09 KB
/
Copy pathAssetPathVersionMetaData.cs
File metadata and controls
75 lines (65 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine.Bindings;
using UnityEngine.Scripting;
namespace UnityEditor.Scripting.ScriptCompilation
{
// Keep in sync with ManagedVersionType in C++
enum VersionType
{
VersionTypeUnity,
VersionTypePackage,
}
[NativeAsStruct]
[StructLayout(LayoutKind.Sequential)]
[RequiredByNativeCode(GenerateProxy = true)]
[NativeHeader("Runtime/Scripting/ScriptingManagedProxySupport.h")]
class VersionMetaData
{
public string Name;
public string Version;
public VersionType Type;
public VersionMetaData(string name)
{
Name = name;
}
public VersionMetaData(string name, string version)
{
Name = name;
Version = version;
}
public VersionMetaData(string name, string version, VersionType type)
{
Name = name;
Version = version;
Type = type;
}
}
class VersionMetaDataComparer : IEqualityComparer<VersionMetaData>
{
public bool Equals(VersionMetaData current, VersionMetaData other)
{
if (current == null || other == null)
{
return current == other;
}
return string.Equals(current.Name, other.Name, StringComparison.Ordinal)
&& string.Equals(current.Version, other.Version, StringComparison.Ordinal)
&& current.Type == other.Type;
}
public int GetHashCode(VersionMetaData obj)
{
unchecked
{
var hashCode = (obj.Name != null ? obj.Name.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (obj.Version != null ? obj.Version.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ obj.Type.GetHashCode();
return hashCode;
}
}
}
}