コード例 #1
0
        private XDocument Serialize(object obj)
        {
            ExtendedTypes.Clear();

            var type = obj.GetType();

            if (type != RootType)
            {
                throw new ArgumentException($"object is not of type {RootType.FullName}", nameof(obj));
            }

            var document = new XDocument();

            var root = SerializeObject(type.Name, obj, type);

            if (NeedSystemNamespace)
            {
                root.Add(new XAttribute(XNamespace.Xmlns + SystemNamespacePrefix, SystemNamespace));
            }
            if (ExtendedTypes.Count > 0)
            {
                foreach (var kvp in ExtendedTypes.OrderBy(kvp => kvp.Value))
                {
                    root.Add(new XAttribute(SystemNamespace + kvp.Value, kvp.Key.AssemblyQualifiedName));
                }
            }

            document.Add(root);

            return(document);
        }
コード例 #2
0
 private XAttribute GetExtendedTypeAttribute(Type type)
 {
     if (!ExtendedTypes.TryGetValue(type, out string name))
     {
         name = $"t{ExtendedTypes.Count + 1}";
         ExtendedTypes[type] = name;
         NeedSystemNamespace = true;
     }
     return(new XAttribute(SystemNamespace + TypeName, name));
 }
コード例 #3
0
        /// <inheritdoc />
        public override string ToDebugString()
        {
            var decorators = ToDebugString(Decorators);

            string typeParameters = TypeParameters.Count > 0
                ? "<" + string.Join(", ", TypeParameters.Select(p => p.ToString())) + ">"
                : string.Empty;
            string extendedTypes = ExtendedTypes.Count > 0
                ? " extends " + string.Join(", ", ExtendedTypes.Select(t => t.ToString()))
                : string.Empty;

            return(decorators + GetModifierString() + "interface " + ToDebugString(Name)
                   + typeParameters
                   + extendedTypes
                   + Body);
        }
コード例 #4
0
        public ExtendedTypes GetExtendedType()
        {
            ExtendedTypes extendType = new ExtendedTypes(typeof(BabylonCamera), typeof(GLTFAnimation));

            return(extendType);
        }
コード例 #5
0
        public override string ToString()
        {
            string result = TypeDescription;

            if (Header.OpcodeType == OpcodeType.Sync)
            {
                result += SyncFlags.GetDescription();
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.SampleControls))
            {
                result += "_aoffimmi";
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.ResourceDim))
            {
                result += "_indexable";
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.SampleControls))
            {
                result += string.Format("({0},{1},{2})", SampleOffsets[0], SampleOffsets[1], SampleOffsets[2]);
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.ResourceDim))
            {
                result += string.Format("({0}", ResourceTarget.GetDescription());
                if (ResourceStride != 0)
                {
                    result += string.Format(", stride={0}", ResourceStride);
                }
                result += ")";
            }

            if (ExtendedTypes.Contains(InstructionTokenExtendedType.ResourceReturnType))
            {
                result += string.Format("({0},{1},{2},{3})",
                                        ResourceReturnTypes[0].GetDescription(),
                                        ResourceReturnTypes[1].GetDescription(),
                                        ResourceReturnTypes[2].GetDescription(),
                                        ResourceReturnTypes[3].GetDescription());
            }

            if (Header.OpcodeType == OpcodeType.Resinfo && ResInfoReturnType != ResInfoReturnType.Float)
            {
                result += string.Format("_{0}", ResInfoReturnType.GetDescription().ToLower());
            }

            if (Header.OpcodeType.IsConditionalInstruction())
            {
                result += "_" + TestBoolean.GetDescription();
            }

            if (Saturate)
            {
                result += "_sat";
            }
            result += " ";

            if (Header.OpcodeType == OpcodeType.InterfaceCall)
            {
                result += string.Format("fp{0}[{1}][{2}]",
                                        Operands[0].Indices[0].Value,
                                        Operands[0].Indices[1],
                                        FunctionIndex);
            }
            else
            {
                for (int i = 0; i < Operands.Count; i++)
                {
                    var operandString = Operands[i].ToString();
                    if (i > 0 && !string.IsNullOrEmpty(operandString))
                    {
                        result += ", ";
                    }
                    result += operandString;
                }
            }

            return(result);
        }
コード例 #6
0
ファイル: ExtendedTypeTest.cs プロジェクト: jgshort/SqlDom
 public void ExtendedTypeConstructorTest()
 {
     ExtendedTypes type = new ExtendedTypes(); // TODO: Initialize to an appropriate value
     ExtendedType target = new ExtendedType(type);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }