当前位置: 首页>>代码示例>>C#>>正文


C# StreamWriterLevel.WL方法代码示例

本文整理汇总了C#中StreamWriterLevel.WL方法的典型用法代码示例。如果您正苦于以下问题:C# StreamWriterLevel.WL方法的具体用法?C# StreamWriterLevel.WL怎么用?C# StreamWriterLevel.WL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StreamWriterLevel的用法示例。


在下文中一共展示了StreamWriterLevel.WL方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeclareType

        public static void DeclareType(SequenceOrSetType pThis, StreamWriterLevel csFile, string TypeName, int level, string baseClassName)
        {
            csFile.WL(level, "public partial class {0} : {1}", TypeName, baseClassName);
            csFile.WL(level++, "{");

            foreach (SequenceOrSetType.Child ch in pThis.m_children.Values)
            {
                csFile.WriteLine();

                ICSharpType childType = ch.m_type as ICSharpType;
                string propName = C.ID(ch.m_childVarName.Substring(0, 1).ToUpper() + ch.m_childVarName.Substring(1));

                if (childType.RequiresNewTypeDeclaration())
                {
                    childType.DeclareType(csFile, propName, level);
                    csFile.WriteLine();
                }

                

                csFile.WL(level, "public {0} {1}", ((ICSharpType)ch.m_type).DeclaredTypeName, C.ID(ch.m_childVarName));
                csFile.WL(level++, "{");

                csFile.WL(level, "get {{ return m_children[ClassDef.m_children[\"{0}\"].m_index] as {1}; }}", C.ID(ch.m_childVarName), ((ICSharpType)ch.m_type).DeclaredTypeName);
                
                csFile.WL(--level, "}");


                csFile.WL(level, "public {0} Create_{1}()", childType.DeclaredTypeName, C.ID(ch.m_childVarName));
                csFile.WL(level++, "{");

//                csFile.WL(level, "return CreateChild(\"{0}\");", C.ID(ch.m_childVarName));
                csFile.WL(level, "return CreateChild(\"{0}\") as {1};", C.ID(ch.m_childVarName), childType.DeclaredTypeName);
                csFile.WL(--level, "}");

            }

            CSharpType.WriteCustomAttrList(pThis, csFile, level);
            CSharpType.WriteEncodeDecodeMethods(pThis, csFile, level);

            csFile.WL(level, "static Asn1CompositeClass<OptionalNamedChild> _clsDef = new {0}ClassDefinition();",TypeName);
            csFile.WL(level, "public override Asn1CompositeClass<OptionalNamedChild> ClassDef");
            csFile.WL(level++, "{");
            csFile.WL(level, "get");
            csFile.WL(level++, "{");
            csFile.WL(level, "return _clsDef;");
            csFile.WL(--level, "}");
            csFile.WL(--level, "}");


            csFile.WL(level, "public {0}()", TypeName);
            csFile.WL(level++, "{");
            csFile.WL(level, "m_children = new Asn1Object[{0}];",pThis.m_children.Count);
            csFile.WL(--level, "}");

//class definition

            csFile.WL(level, "public class {0}ClassDefinition : Asn1CompositeClass<OptionalNamedChild>", TypeName);
            csFile.WL(level++, "{");

            csFile.WL(level, "public {0}ClassDefinition()", TypeName);
            csFile.WL(level++, "{");


            csFile.WL(level, "OptionalNamedChild ch;");
            int idx = 0;
            foreach (SequenceOrSetType.Child ch in pThis.m_children.Values)
            {

                ICSharpType childType = ch.m_type as ICSharpType;

                csFile.WL(level, "ch = new OptionalNamedChild(\"{0}\", {1}, Create{2}, {3}, null);", C.ID(ch.m_childVarName), idx,
//                csFile.WL(level, "ch = new OptionalNamedChild(\"{0}\", {1}, delegate() {{return new {2}();}}, {3}, null);", C.ID(ch.m_childVarName), idx,
                    childType.DeclaredTypeName, (ch.m_optional ? "true" : "false"));
                idx++;

                ChoiceType chChild = ch.m_type.GetFinalType() as ChoiceType;
                if (chChild != null && !ch.m_type.IsTagged())
                {
//                    csFile.WL(level, "ch.UnTaggedChoice = true;");
//                    csFile.WL(level, "ch.m_childrenTags = new List<Tag>();");

                    List<Asn1Type.TagSequence> tags = chChild.getChildrenTags();
                    foreach (Asn1Type.TagSequence tgSq in tags)
                    {
//                        csFile.WL(level, "ch.m_childrenTags.Add(new Tag({0}, TagClass.{1}));", tgSq.m_tags[0].m_tag, tgSq.m_tags[0].m_class);

                        csFile.WL(level, "m_posChildren.Add(0x{0:X}, ch);", CalculateTag(tgSq.m_tags[0]));
                    }
                }
                else
                {
                    Asn1Type.Tag lstTag = ch.m_type.Tags.m_tags[0];
//                    csFile.WL(level, "ch.m_Tag = new Tag({0}, TagClass.{1});", lstTag.m_tag, lstTag.m_class);

                    csFile.WL(level, "m_posChildren.Add(0x{0:X}, ch);", CalculateTag(lstTag));
                }

                
                csFile.WL(level, "m_children.Add(\"{0}\", ch);", C.ID(ch.m_childVarName));
//.........这里部分代码省略.........
开发者ID:kia92798,项目名称:tinyasn1,代码行数:101,代码来源:CSharpCompositeTypes.cs

示例2: WriteEncodeDecodeMethods

        public static void WriteEncodeDecodeMethods(Asn1Type pThis, StreamWriterLevel csFile, int level)
        {
            if (pThis.m_tag == null)
                return;
            csFile.WriteLine();
            csFile.WL(level, "public override uint Encode(Stream strm, EncodingRules encRule)");
            csFile.WL(level++, "{");
            if (pThis.m_tag.m_taggingMode== TaggingMode.EXPLICIT)
            //                csFile.WL(level, "return Encode(strm, encRule, TagClass.{0}, false, {1});", pThis.m_tag.m_class, pThis.m_tag.m_tag);
                csFile.WL(level, "return Encode(strm, encRule, false, 0x{0:X});", CSharpSequenceOrSetType.CalculateTag(pThis.m_tag));
            else
                csFile.WL(level, "return Encode(strm, encRule, IsPrimitive, 0x{0:X});", CSharpSequenceOrSetType.CalculateTag(pThis.m_tag));
            //                csFile.WL(level, "return Encode(strm, encRule, TagClass.{0}, IsPrimitive, {1});", pThis.m_tag.m_class, pThis.m_tag.m_tag);
            csFile.WL(--level, "}");

            csFile.WriteLine();
            csFile.WL(level, "public override uint Decode(Stream strm, EncodingRules encRule)");
            csFile.WL(level++, "{");
            if (pThis.m_tag.m_taggingMode == TaggingMode.EXPLICIT)
                csFile.WL(level, "return Decode(strm, encRule, false, 0x{0:X});", CSharpSequenceOrSetType.CalculateTag(pThis.m_tag));
            //                csFile.WL(level, "return Decode(strm, encRule, TagClass.{0}, false, {1});", pThis.m_tag.m_class, pThis.m_tag.m_tag);
            else
                csFile.WL(level, "return Decode(strm, encRule, IsPrimitive, 0x{0:X});", CSharpSequenceOrSetType.CalculateTag(pThis.m_tag));
            //                csFile.WL(level, "return Decode(strm, encRule, TagClass.{0}, IsPrimitive, {1});", pThis.m_tag.m_class, pThis.m_tag.m_tag);
            csFile.WL(--level, "}");

            if (pThis.m_tag.m_taggingMode == TaggingMode.EXPLICIT)
            {
                csFile.WriteLine();
                csFile.WL(level, "public override uint EncodeContent(Stream strm, EncodingRules encRule)");
                csFile.WL(level++, "{");
                csFile.WL(level, "return base.Encode(strm, encRule);");
                csFile.WL(--level, "}");

                csFile.WriteLine();
                csFile.WL(level, "public override uint DecodeContent(Stream strm, EncodingRules encRule, uint dataLen)");
                csFile.WL(level++, "{");
                csFile.WL(level, "return base.Decode(strm, encRule);");
                csFile.WL(--level, "}");
            }
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:41,代码来源:CSharpType.cs

示例3: WriteIsConstraintValid

        public static void WriteIsConstraintValid(Asn1Type pThis, StreamWriterLevel csFile, int level, 
            string valueName, string enumPrefix)
        {
            if (pThis.m_constraints.Count == 0)
                return;

            csFile.WL(level, "public override bool IsConstraintValid()");
            csFile.WL(level++, "{");
            csFile.P(level);
            csFile.Write("return ");
            foreach (ICSharpConstraint con in pThis.m_constraints)
            {
                csFile.Write("{0} && ",con.PrintConstraintCode(valueName,enumPrefix));

            }
            csFile.WriteLine("base.IsConstraintValid();");
            csFile.WL(--level, "}");
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:18,代码来源:CSharpType.cs

示例4: WriteCustomAttrList

        public static void WriteCustomAttrList(Asn1Type pThis, StreamWriterLevel csFile, int level)
        {
            if (pThis.m_CustomAttributes.Count == 0)
                return;
            csFile.WL(level, "private static Dictionary<string, string> m_CustomAttrs = new Dictionary<string, string>()");
            csFile.WL(level++, "{");
            foreach (var kv in pThis.m_CustomAttributes)
            {
                csFile.WL(level, "{{\"{0}\",\"{1}\"}},", kv.Key, kv.Value);
            }

            csFile.WL(--level, "};");
            csFile.WL(level, "public override Dictionary<string, string> CustomAttrs { get { return m_CustomAttrs; } }");
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:14,代码来源:CSharpType.cs

示例5: DeclareType

        public static void DeclareType(Asn1Type pThis, StreamWriterLevel csFile, string TypeName, int level, string baseClassName,
            out string DeclaredTypeName, string valueName, string enumPrefix)
        {
            DeclaredTypeName = TypeName;

            csFile.WL(level, "public partial class {0} : {1}", DeclaredTypeName, baseClassName);
            csFile.WL(level++, "{");
            WriteCustomAttrList(pThis, csFile, level);
            WriteEncodeDecodeMethods(pThis, csFile, level);
            WriteIsConstraintValid(pThis, csFile, level, valueName, enumPrefix);
            csFile.WL(--level, "}");
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:12,代码来源:CSharpType.cs

示例6: WriteConstructorCodeA

        public static void WriteConstructorCodeA(ArrayType pThis, StreamWriterLevel csFile, int level, string pThisString, List<IConstraint> constraints, Asn1Type.Tag tag)
        {
            int levCount=0;
            StackTrace str = new StackTrace();
            foreach (StackFrame frm in str.GetFrames())
                if (frm.GetMethod().Name.Contains("WriteConstructorCodeA"))
                    levCount++;

            string retVarName = "ch" + levCount.ToString();
            ICSharpType childType = pThis.m_type as ICSharpType;

            string prefix = pThisString;
            if (pThisString != "")
                prefix += ".";

            csFile.WL(level, "{0}m_child.createObj = new Func<{1}>(delegate()", prefix,childType.DeclaredTypeName);
            csFile.WL(level++, "{");
            csFile.WL(level, "{0} {1} = new {0}();", childType.DeclaredTypeName, retVarName);
            csFile.WL(level, "return {0};", retVarName);
            csFile.WL(--level, "});");

            ChoiceType chChild = pThis.m_type.GetFinalType() as ChoiceType;
            if (chChild != null && !pThis.m_type.IsTagged())
            {
                csFile.WL(level, "{0}m_child.UnTaggedChoice = true;", prefix);
                csFile.WL(level, "{0}m_child.m_childrenTags = new List<Tag>();", prefix);

                List<Asn1Type.TagSequence> tags = chChild.getChildrenTags();
                foreach (Asn1Type.TagSequence tgSq in tags)
                {
                    csFile.WL(level, "{0}m_child.m_childrenTags.Add(new Tag({1}, TagClass.{2}));",prefix, tgSq.m_tags[0].m_tag, tgSq.m_tags[0].m_class);
                }
            }
            else
            {
                Asn1Type.Tag lstTag = pThis.m_type.Tags.m_tags[0];
                csFile.WL(level, "{0}m_child.m_Tag = new Tag({1}, TagClass.{2});",prefix, lstTag.m_tag, lstTag.m_class);

            }
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:40,代码来源:CSharpArrayType.cs

示例7: DeclareTypeA

        public static void DeclareTypeA(ArrayType pThis, StreamWriterLevel csFile, string TypeName, int level,
            string baseClassName, out string DeclaredTypeName)
        {
            ICSharpType childType = pThis.m_type as ICSharpType;

            if (childType.RequiresNewTypeDeclaration())
            {
                DeclaredTypeName = TypeName;

                string internalTypeName = "InternalType";

                int levCount = 0;
                StackTrace str = new StackTrace();
                foreach (StackFrame frm in str.GetFrames())
                    if (frm.GetMethod().Name.Contains("DeclareTypeA"))
                        levCount++;
                if (levCount > 1)
                    internalTypeName += (--levCount).ToString();

                csFile.WL(level, "public partial class {0} : {1}<{0}.{2}>", TypeName, baseClassName, internalTypeName);
                csFile.WL(level++, "{");

                childType.DeclareType(csFile, internalTypeName, level);
                csFile.WriteLine();
            }
            else
            {
                DeclaredTypeName = baseClassName + "<" + childType.DeclaredTypeName + ">";
                csFile.WL(level, "public partial class {0} : {1}<{2}>", TypeName, baseClassName, childType.DeclaredTypeName);
                csFile.WL(level++, "{");
            }

            CSharpType.WriteCustomAttrList(pThis, csFile, level);
            CSharpType.WriteEncodeDecodeMethods(pThis, csFile, level);
            CSharpType.WriteIsConstraintValid(pThis, csFile, level, "m_children", "");

            string childTags = string.Empty;
            int chTagsNo=0;
            ChoiceType chChild = pThis.m_type.GetFinalType() as ChoiceType;
            if (chChild != null && !pThis.m_type.IsTagged())
            {
                List<Asn1Type.TagSequence> tags = chChild.getChildrenTags();
                foreach (Asn1Type.TagSequence tgSq in tags) {
                    childTags += string.Format("0x{0:X},", CSharpSequenceOrSetType.CalculateTag(tgSq.m_tags[0]));
                    chTagsNo++;
                }
                childTags = childTags.Substring(0, childTags.Length - 1);
            }
            else
            {
                Asn1Type.Tag lstTag = pThis.m_type.Tags.m_tags[0];
                childTags = string.Format("0x{0:X}", CSharpSequenceOrSetType.CalculateTag(lstTag));
                chTagsNo=1;
            }
            csFile.WL(level, "static List<UInt32> _childTags = new List<UInt32>( new UInt32[{0}] {{ {1} }} );", chTagsNo, childTags);
            csFile.WL(level, "protected override List<UInt32> ChildTags { get { return _childTags; } }");

            csFile.WL(level, "protected override Func<{0}> CreateEmptyChild {{ get {{ return delegate() {{ return new {0} (); }}; }} }}", childType.DeclaredTypeName);

            //csFile.WL(level, "public {0}()", TypeName);
            //csFile.WL(level++, "{");
            //WriteConstructorCodeA(pThis, csFile, level, "", pThis.m_constraints, pThis.m_tag);
            //csFile.WL(--level, "}");

            csFile.WL(--level, "}");
        }
开发者ID:kia92798,项目名称:tinyasn1,代码行数:66,代码来源:CSharpArrayType.cs


注:本文中的StreamWriterLevel.WL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。