示例#1
0
        public FScriptSetHelper(IntPtr setProperty, IntPtr set)
        {
            this.setProperty = setProperty;
            this.set         = (FScriptSet *)set;
            setLayout        = Native_USetProperty.Get_SetLayout(setProperty);

            elementProp     = Native_USetProperty.Get_ElementProp(setProperty);
            elementSize     = Native_UProperty.Get_ElementSize(elementProp);
            elementArrayDim = Native_UProperty.Get_ArrayDim(elementProp);
        }
示例#2
0
文件: TSet.cs 项目: yimengfan/USharp
        internal static void ToNativeInternal(IntPtr nativeBuffer, int arrayIndex, IEnumerable <T> value,
                                              ref FScriptSetHelper helper, MarshalingDelegates <T> .ToNative elementToNative)
        {
            IntPtr scriptSetAddress = nativeBuffer + (arrayIndex * Marshal.SizeOf(typeof(FScriptSet)));

            helper.Set = scriptSetAddress;

            // Make sure any existing elements are properly destroyed
            helper.EmptyValues();

            if (value == null)
            {
                return;
            }

            unsafe
            {
                FScriptSet *set = (FScriptSet *)scriptSetAddress;

                IList <T> list = value as IList <T>;
                if (list != null)
                {
                    for (int i = 0; i < list.Count; ++i)
                    {
                        helper.AddElement(list[i], elementToNative);
                    }
                    return;
                }

                HashSet <T> hashSet = value as HashSet <T>;
                if (hashSet != null)
                {
                    foreach (T item in hashSet)
                    {
                        helper.AddElement(item, elementToNative);
                    }
                    return;
                }

                TSetBase <T> setBase = value as TSetBase <T>;
                if (setBase != null)
                {
                    foreach (T item in setBase)
                    {
                        helper.AddElement(item, elementToNative);
                    }
                    return;
                }

                foreach (T item in value)
                {
                    helper.AddElement(item, elementToNative);
                }
            }
        }
示例#3
0
文件: TSet.cs 项目: yimengfan/USharp
        public TSetBase(UObject owner, UFieldAddress setProperty, IntPtr address,
                        MarshalingDelegates <T> .FromNative fromNative, MarshalingDelegates <T> .ToNative toNative)
        {
            property = setProperty;
            set      = (FScriptSet *)address;

            SetHelper = new FScriptSetHelper(property.Address, address);

            Owner      = owner;
            FromNative = fromNative;
            ToNative   = toNative;

            ContainerHashValidator.Validate(Native_USetProperty.Get_ElementProp(setProperty.Address));
        }
示例#4
0
        public static ISet <T> FromNative(IntPtr nativeBuffer, int arrayIndex, IntPtr prop)
        {
            IntPtr           scriptSetAddress = nativeBuffer + (arrayIndex * Marshal.SizeOf(typeof(FScriptSet)));
            FScriptSetHelper helper           = new FScriptSetHelper(prop, scriptSetAddress);

            unsafe
            {
                FScriptSet *set    = (FScriptSet *)scriptSetAddress;
                HashSet <T> result = new HashSet <T>();
                int         count  = set->Count;
                for (int i = 0; i < count; ++i)
                {
                    result.Add(elementFromNative(helper.GetElementPtr(i), 0, helper.ElementPropertyAddress));
                }
                return(result);
            }
        }
示例#5
0
文件: TSet.cs 项目: yimengfan/USharp
        public HashSet <T> FromNative(IntPtr nativeBuffer, int arrayIndex, IntPtr prop)
        {
            IntPtr scriptSetAddress = nativeBuffer + (arrayIndex * Marshal.SizeOf(typeof(FScriptSet)));

            helper.Update(property);
            helper.Set = scriptSetAddress;

            unsafe
            {
                FScriptSet *set      = (FScriptSet *)scriptSetAddress;
                HashSet <T> result   = new HashSet <T>();
                int         maxIndex = set->GetMaxIndex();
                for (int i = 0; i < maxIndex; ++i)
                {
                    if (set->IsValidIndex(i))
                    {
                        result.Add(elementFromNative(helper.GetElementPtr(i), 0, helper.ElementPropertyAddress));
                    }
                }
                return(result);
            }
        }