Process() public static method

Generates serialization methods for synclists
public static Process ( TypeDefinition td, TypeReference mirrorBaseType ) : void
td TypeDefinition The synclist class
mirrorBaseType TypeReference the base SyncObject td inherits from
return void
Exemplo n.º 1
0
        private static bool CheckSyncList(TypeDefinition td)
        {
            if (!td.IsClass)
            {
                return(false);
            }

            var didWork = false;

            // are ANY parent classes SyncListStruct
            var parent = td.BaseType;

            while (parent != null)
            {
                if (parent.FullName.StartsWith(SyncListType.FullName, StringComparison.Ordinal))
                {
                    SyncListProcessor.Process(td);
                    didWork = true;
                    break;
                }

                if (parent.FullName.StartsWith(SyncSetType.FullName, StringComparison.Ordinal))
                {
                    SyncListProcessor.Process(td);
                    didWork = true;
                    break;
                }

                if (parent.FullName.StartsWith(SyncDictionaryType.FullName, StringComparison.Ordinal))
                {
                    SyncDictionaryProcessor.Process(td);
                    didWork = true;
                    break;
                }

                try
                {
                    parent = parent.Resolve().BaseType;
                }
                catch (AssemblyResolutionException)
                {
                    // this can happen for pluins.
                    //Console.WriteLine("AssemblyResolutionException: "+ ex.ToString());
                    break;
                }
            }

            // check for embedded types
            foreach (var embedded in td.NestedTypes)
            {
                didWork |= CheckSyncList(embedded);
            }

            return(didWork);
        }
Exemplo n.º 2
0
        static bool WeaveSyncObject(TypeDefinition td)
        {
            if (!td.IsClass)
            {
                return(false);
            }

            bool modified = false;

            // are ANY parent classes SyncListStruct
            TypeReference parent = td.BaseType;

            while (parent != null)
            {
                if (parent.FullName.StartsWith(SyncListType.FullName, StringComparison.Ordinal))
                {
                    SyncListProcessor.Process(td);
                    modified = true;
                    break;
                }
                if (parent.FullName.StartsWith(SyncSetType.FullName, StringComparison.Ordinal))
                {
                    SyncListProcessor.Process(td);
                    modified = true;
                    break;
                }
                if (parent.FullName.StartsWith(SyncDictionaryType.FullName, StringComparison.Ordinal))
                {
                    SyncDictionaryProcessor.Process(td);
                    modified = true;
                    break;
                }
                try
                {
                    parent = parent.Resolve().BaseType;
                }
                catch (AssemblyResolutionException)
                {
                    // this can happen for pluins.
                    //Console.WriteLine("AssemblyResolutionException: "+ ex.ToString());
                    break;
                }
            }

            // check for embedded types
            foreach (TypeDefinition embedded in td.NestedTypes)
            {
                modified |= WeaveSyncObject(embedded);
            }

            return(modified);
        }
Exemplo n.º 3
0
        static bool WeaveSyncObject(TypeDefinition td)
        {
            bool modified = false;

            // ignore generic classes
            // we can not process generic classes
            // we give error if a generic syncObject is used in NetworkBehaviour
            if (td.HasGenericParameters)
            {
                return(false);
            }

            // ignore abstract classes
            // we dont need to process abstract classes because classes that
            // inherit from them will be processed instead

            // We cant early return with non classes or Abstract classes
            // because we still need to check for embeded types
            if (td.IsClass || !td.IsAbstract)
            {
                if (td.IsDerivedFrom(WeaverTypes.SyncListType))
                {
                    SyncListProcessor.Process(td, WeaverTypes.SyncListType);
                    modified = true;
                }
                else if (td.IsDerivedFrom(WeaverTypes.SyncSetType))
                {
                    SyncListProcessor.Process(td, WeaverTypes.SyncSetType);
                    modified = true;
                }
                else if (td.IsDerivedFrom(WeaverTypes.SyncDictionaryType))
                {
                    SyncDictionaryProcessor.Process(td);
                    modified = true;
                }
            }

            // check for embedded types
            foreach (TypeDefinition embedded in td.NestedTypes)
            {
                modified |= WeaveSyncObject(embedded);
            }

            return(modified);
        }
Exemplo n.º 4
0
        static bool WeaveSyncObject(TypeDefinition td)
        {
            if (!td.IsClass)
            {
                return(false);
            }

            // ignore generic classes
            // we can not process generic classes
            // we give error if a generic syncObject is used in NetworkBehaviour
            if (td.HasGenericParameters)
            {
                return(false);
            }

            bool modified = false;

            if (td.IsDerivedFrom(SyncListType))
            {
                SyncListProcessor.Process(td);
                modified = true;
            }
            else if (td.IsDerivedFrom(SyncSetType))
            {
                SyncListProcessor.Process(td);
                modified = true;
            }
            else if (td.IsDerivedFrom(SyncDictionaryType))
            {
                SyncDictionaryProcessor.Process(td);
                modified = true;
            }

            // check for embedded types
            foreach (TypeDefinition embedded in td.NestedTypes)
            {
                modified |= WeaveSyncObject(embedded);
            }

            return(modified);
        }