Beispiel #1
0
        private void _WriteGetMetadataTypeMethod(Type type)
        {
            _writer.WriteLine("[Export(ExportFlags.AutoCode)]");

            if (_rootTypes.Contains(type))
            {
                _writer.WriteLine("public virtual ushort GetMetadataType ()");
                using (CodeScope.CreateCSharpScope(_writer))
                {
                    _writer.WriteLine("throw new NotImplementedException(\"This method should be override~\");");
                }
            }
            else
            {
                var overrideText = _rootTypes.Contains(EditorMetaCommon.GetRootMetadata(type)) ? "override " : string.Empty;
                _writer.WriteLine("public {0}ushort GetMetadataType ()", overrideText);

                using (CodeScope.CreateCSharpScope(_writer))
                {
                    //var typeName = EditorMetaCommon.GetMetaTypeName(type);
                    //_writer.WriteLine("return (ushort) MetadataType.{0};", typeName);
                    _writer.WriteLine("throw new NotImplementedException(\"This method should be override~\");");
                }
            }
        }
Beispiel #2
0
        private void _WriteSaveMethod(Type type, List <MemberBase> members)
        {
            if (_rootTypes.Contains(type))
            {
                _writer.WriteLine("[Export(ExportFlags.AutoCode)]");
                _writer.WriteLine("public virtual void Save (IOctetsWriter writer)");
                using (CodeScope.CreateCSharpScope(_writer))
                {
                    _writer.WriteLine("throw new NotImplementedException(\"This method should be override~\");");
                }
            }
            else
            {
                using (MacroScope.CreateEditorScope(_writer.BaseWriter))
                {
                    _writer.WriteLine("[Export(ExportFlags.AutoCode)]");

                    var overrideText = _rootTypes.Contains(EditorMetaCommon.GetRootMetadata(type)) ? "override " : string.Empty;
                    _writer.WriteLine("public {0}void Save (IOctetsWriter writer)", overrideText);
                    using (CodeScope.Create(_writer, "{\n", "}\n"))
                    {
                        for (int index = 0; index < members.Count; ++index)
                        {
                            var member = members[index];
                            member.WriteSave(_writer);
                        }
                    }
                }
            }
        }
Beispiel #3
0
 private void _InitRootTypes(MetaManager metaManager)
 {
     foreach (var type in metaManager.MetaTypes)
     {
         var rootType = EditorMetaCommon.GetRootMetadata(type.RawType);
         if (type.RawType != rootType)
         {
             _rootTypes.Add(rootType);
         }
     }
 }
Beispiel #4
0
        private void _WriteEqualsToMethod(Type type, List <MemberBase> members)
        {
            _writer.WriteLine("[Export(ExportFlags.AutoCode)]");
            if (_rootTypes.Contains(type))
            {
                _writer.WriteLine("public virtual bool EqualsTo (IMetadata other)");
                using (CodeScope.CreateCSharpScope(_writer))
                {
                    _writer.WriteLine("throw new NotImplementedException(\"This method should be override~\");");
                }
            }
            else
            {
                var overrideText = _rootTypes.Contains(EditorMetaCommon.GetRootMetadata(type)) ? "override " : string.Empty;
                _writer.WriteLine("public {0}bool EqualsTo (IMetadata other)", overrideText);

                using (CodeScope.CreateCSharpScope(_writer))
                {
                    var typeName = EditorMetaCommon.GetNestedClassName(type);
                    _writer.WriteLine("var that = ({0}) other;", typeName);

                    if (type.IsClass)
                    {
                        _writer.WriteLine("if (null == that)");
                        using (CodeScope.CreateCSharpScope(_writer))
                        {
                            _writer.WriteLine("return false;");
                        }
                    }

                    var memberCount = members.Count;

                    for (int index = 0; index < memberCount; ++index)
                    {
                        var member = members[index];
                        member.WriteNotEqualsReturn(_writer);
                    }

                    _writer.WriteLine("return true;");
                }
            }
        }