Example #1
0
        public bool Initialize(bool beforeFieldInit, object state)
        {
            if (beforeFieldInit)
            {
                return(false);
            }

            //REVISIT
            //ChoProfile.InitializeProfile(GetType());

            ChoDictionary <string, string> typeShortNameMap = ChoDictionary <string, string> .Synchronized(new ChoDictionary <string, string>());

            using (ChoBufferProfileEx errProfile = ChoBufferProfileEx.DelayedAutoStart(new ChoBufferProfileEx(true, ChoPath.AddExtension(typeof(ChoTypeFactory).FullName, ChoReservedFileExt.Err), "Below are the duplicate type short names founds...")))
            {
                foreach (Type type in ChoType.GetTypes(typeof(ChoTypeShortNameAttribute)))
                {
                    ChoTypeShortNameAttribute typeShortNameAttribute = ChoType.GetAttribute <ChoTypeShortNameAttribute>(type);
                    AddToMap(typeShortNameMap, errProfile, type, typeShortNameAttribute.Name, false);
                }
                if (ChoShortTypeNameSettings.Me.ValidTypsShortNames != null)
                {
                    foreach (ChoTypsShortName typsShortName in ChoShortTypeNameSettings.Me.ValidTypsShortNames)
                    {
                        if (typsShortName.Type == null)
                        {
                            continue;
                        }
                        AddToMap(typeShortNameMap, errProfile, typsShortName.Type, typsShortName.TypeShortName, typsShortName.Override);
                    }
                }
            }
            lock (_padLock)
            {
                _typeShortNameMap = typeShortNameMap;
            }

            return(false);
        }