Esempio n. 1
0
        protected override void AddStaticConstructor()
        {
            if (_t.IsInterface)
            {
                _sb.AppendLine("static " + _t.Name + "::" + _t.Name + "()");
            }
            else
            {
                _sb.AppendLine("static " + _t.CLRName + "::" + _t.CLRName + "()");
            }

            _sb.AppendLine("{");
            _sb.IncreaseIndent();
            foreach (DefMember m in _cachedMembers)
            {
                if (m.IsStatic)
                {
                    _sb.AppendIndent(NameToPrivate(m) + " = ");
                    if (m.ProtectionType == ProtectionType.Protected)
                    {
                        _sb.Append(NativeProtectedTypesProxy.GetProtectedTypesProxyName(m.Class));
                        _sb.Append("::" + m.Name + ";\n");
                    }
                    else
                    {
                        _sb.Append(m.Class.FullNativeName);
                        _sb.Append("::" + m.Name + ";\n");
                    }
                }
            }
            _sb.DecreaseIndent();
            _sb.AppendLine("}");
        }
Esempio n. 2
0
        protected override void GenerateCodeStaticConstructor()
        {
            if (_classDefinition.IsInterface)
            {
                _codeBuilder.AppendLine("static " + _classDefinition.Name + "::" + _classDefinition.Name + "()");
            }
            else
            {
                _codeBuilder.AppendLine("static " + _classDefinition.CLRName + "::" + _classDefinition.CLRName + "()");
            }

            _codeBuilder.AppendLine("{");
            _codeBuilder.IncreaseIndent();
            foreach (MemberDefinitionBase m in _cachedMembers)
            {
                if (m.IsStatic)
                {
                    _codeBuilder.AppendIndent(NameToPrivate(m) + " = ");
                    if (m.ProtectionLevel == ProtectionLevel.Protected)
                    {
                        _codeBuilder.Append(NativeProtectedTypesProxy.GetProtectedTypesProxyName(m.ContainingClass));
                        _codeBuilder.Append("::" + m.NativeName + ";\n");
                    }
                    else
                    {
                        _codeBuilder.Append(m.ContainingClass.FullyQualifiedNativeName);
                        _codeBuilder.Append("::" + m.NativeName + ";\n");
                    }
                }
            }
            _codeBuilder.DecreaseIndent();
            _codeBuilder.AppendLine("}");
        }