• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CodeProcessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CodeProcessor的典型用法代码示例。如果您正苦于以下问题:C# CodeProcessor类的具体用法?C# CodeProcessor怎么用?C# CodeProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CodeProcessor类属于命名空间,在下文中一共展示了CodeProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BuildComplexTypeParser_Collection

        public static void BuildComplexTypeParser_Collection(string cx, Hashtable SequenceTable, Hashtable ChoiceTable, ref int SeqX, ref int ChoX, CodeProcessor cs, UPnPComplexType.ItemCollection ic, string pc_methodPrefix)
        {
            int x = 0;
            string prefix = "";
            int SeqX2 = 0;
            int ChoX2 = 0;

            if (ic.GetType() == typeof(UPnPComplexType.Sequence))
            {
                ++SeqX;
                if (cx == "")
                {
                    cx += "_sequence_" + SeqX.ToString();
                }
                else
                {
                    cx += "->_sequence_" + SeqX.ToString();
                }
                prefix = cx + "->";
            }
            else if (ic.GetType() == typeof(UPnPComplexType.Choice))
            {
                ++ChoX;
                if (cx == "")
                {
                    cx += "_choice_" + ChoX.ToString();
                }
                else
                {
                    cx += "->_choice_" + ChoX.ToString();
                }
                prefix = cx + "->";
            }

            foreach (UPnPComplexType.ContentData cd in ic.Items)
            {
                ++x;
                cs.Append("	if (node->NameLength==" + cd.Name.Length.ToString() + " && memcmp(node->Name,\"" + cd.Name + "\"," + cd.Name.Length.ToString() + ")==0)" + cl);
                cs.Append("	{" + cl);
                if (x == 1)
                {
                    Stack st = new Stack();
                    UPnPComplexType.ItemCollection tc = ic;
                    DText pp = new DText();
                    pp.ATTRMARK = "->";
                    pp[0] = cx;
                    int ppx = pp.DCOUNT();
                    while (tc != null)
                    {
                        string ps;

                        ps = "RetVal";
                        for (int i = 1; i <= ppx; ++i)
                        {
                            ps += ("->" + pp[i]);
                        }
                        st.Push(new object[2] { ps, tc });
                        --ppx;
                        tc = tc.ParentCollection;
                    }
                    while (st.Count > 0)
                    {
                        object[] foo = (object[])st.Pop();
                        cs.Append("	if (" + (string)foo[0] + " == NULL)" + cl);
                        cs.Append("	{" + cl);
                        if (foo[1].GetType() == typeof(UPnPComplexType.Sequence))
                        {
                            cs.Append("	if ((" + (string)foo[0] + " = (struct SEQUENCE_" + SequenceTable[foo[1]].ToString() + "*)malloc(sizeof(struct SEQUENCE_" + SequenceTable[foo[1]].ToString() + "))) == NULL) ILIBCRITICALEXIT(254);" + cl);
                            cs.Append("	memset(" + (string)foo[0] + ",0,sizeof(struct SEQUENCE_" + SequenceTable[foo[1]].ToString() + "));" + cl);
                        }
                        else if (foo[1].GetType() == typeof(UPnPComplexType.Choice))
                        {
                            cs.Append("	if ((" + (string)foo[0] + " = (struct CHOICE_" + ChoiceTable[foo[1]].ToString() + "*)malloc(sizeof(struct CHOICE_" + ChoiceTable[foo[1]].ToString() + "))) == NULL) ILIBCRITICALEXIT(254);" + cl);
                            cs.Append("	memset(" + (string)foo[0] + ",0,sizeof(struct CHOICE_" + ChoiceTable[foo[1]].ToString() + "));" + cl);
                        }
                        cs.Append("	}" + cl);
                    }

                    //					if (ic.GetType()==typeof(UPnPComplexType.Sequence))
                    //					{
                    //						cs.Append("	RetVal->"+cx+" = (struct SEQUENCE_"+SequenceTable[ic].ToString()+"*)malloc(sizeof(struct SEQUENCE_"+SequenceTable[ic].ToString()+"));"+cl);
                    //					}
                    //					else if (ic.GetType()==typeof(UPnPComplexType.Choice))
                    //					{
                    //						cs.Append("	RetVal->"+cx+" = (struct CHOICE_"+ChoiceTable[ic].ToString()+"*)malloc(sizeof(struct CHOICE_"+ChoiceTable[ic].ToString()+"));"+cl);
                    //					}
                }
                if (cd.TypeNS == "http://www.w3.org/2001/XMLSchema")
                {
                    // XSD Simple Type
                    switch (cd.Type)
                    {
                        case "boolean":
                        case "int":
                        case "integer":
                        case "positiveInteger":
                        case "negativeInteger":
                        case "nonNegativeInteger":
                        case "nonPositiveInteger":
                        case "long":
//.........这里部分代码省略.........
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:101,代码来源:EmbeddedCGenerator.cs


示例2: Build_UPnPMiniWebServer

        public bool Build_UPnPMiniWebServer(DirectoryInfo outputDirectory)
        {
            StreamWriter writer;

            if (this.Platform == PLATFORMS.POSIX)
            {
                if (this.SubTarget == SUBTARGETS.NUCLEUS)
                {
                    pc_SockType = "int";
            //					pc_TimeType = "Timeval";
                    pc_SockClose = "NU_Close_Socket";
            //					pc_stricmp = "strncasecmp";
                }
                else
                {
                    pc_SockType = "int";
            //					pc_TimeType = "struct timeval";
                    pc_SockClose = "close";
            //					pc_stricmp = "strncasecmp";
                }
            }

            if (this.Platform == PLATFORMS.WINDOWS)
            {
                pc_SockType = "SOCKET";
            //				pc_TimeType = "unsigned int";
                pc_SockClose = "closesocket";
            //				pc_stricmp = "_strnicmp";
            }

            if (this.Language == LANGUAGES.C)
            {
                pc_methodPrefix = CallPrefix;
                pc_methodLibPrefix = CallLibPrefix;
                pc_methodPrefixDef = CallingConvention + CallPrefix;
            }

            CodeProcessor cs = new CodeProcessor(new StringBuilder(),this.Language == LANGUAGES.CPP);

            /* Build UPnPMiniWebServer.h */
            AddLicense(cs,pc_methodPrefix+"MiniWebServer.h");

            cs.Append(cl);

            cs.Append("#ifndef __"+pc_methodPrefix+"MiniWebServer__"+cl);
            cs.Append("#define __"+pc_methodPrefix+"MiniWebServer__"+cl);

            cs.Append(cl);
            cs.Comment("Forward Declaration");
            cs.Append("struct packetheader;"+cl+cl);

            cs.Append("void* "+pc_methodPrefix+"CreateMiniWebServer(void *chain,int MaxSockets,void (*OnReceive) (void *ReaderObject, struct packetheader *header, char* buffer, int *BeginPointer, int BufferSize, int done, void* user),void *user);"+cl);
            cs.Append("void "+pc_methodPrefix+"DestroyMiniWebServer(void *WebServerModule);"+cl);
            cs.Append("void "+pc_methodPrefix+"StartMiniWebServerModule(void *WebServerModule);"+cl);
            cs.Append("void "+pc_methodPrefix+"StopMiniWebServerModule(void *WebServerModule);"+cl);
            cs.Append(cl);
            cs.Append("void "+pc_methodPrefix+"MiniWebServer_SetReserved(void *MWS, void *object);"+cl);
            cs.Append("void *"+pc_methodPrefix+"MiniWebServer_GetReserved(void *MWS);"+cl);
            cs.Append("void *"+pc_methodPrefix+"MiniWebServer_GetMiniWebServerFromReader(void *Reader);"+cl);
            cs.Append(cl);
            cs.Append("int "+pc_methodPrefix+"GetMiniWebServerPortNumber(void *WebServerModule);"+cl);
            cs.Append("void "+pc_methodPrefix+"MiniWebServerSend(void *ReaderObject, struct packetheader *packet);"+cl);
            cs.Append("void "+pc_methodPrefix+"MiniWebServerCloseSession(void *ReaderObject);"+cl);
            cs.Append(cl);
            cs.Append("char* "+pc_methodPrefix+"GetReceivingInterface(void* ReaderObject);"+cl);
            cs.Append("void "+pc_methodPrefix+"CloseRequest(void* ReaderObject);	"+cl);

            cs.Append(cl);
            cs.Append("#endif"+cl);

            writer = File.CreateText(outputDirectory.FullName + "\\"+pc_methodPrefix+"MiniWebServer.h");
            writer.Write(cs.ToString());
            writer.Close();

            /* Build UPnPMiniWebServer.c */
            cs = new CodeProcessor(new StringBuilder(),this.Language == LANGUAGES.CPP);
            if (this.Language == LANGUAGES.CPP)
            {
                AddLicense(cs,pc_methodPrefix+"MiniWebServer.cpp");
            }
            else
            {
                AddLicense(cs,pc_methodPrefix+"MiniWebServer.c");
            }
            cs.Append(cl);

            if (this.Platform==PLATFORMS.WINDOWS)
            {
                cs.Append("#ifndef MICROSTACK_NO_STDAFX"+cl);
                cs.Append("#include \"stdafx.h\""+cl);
                cs.Append("#endif"+cl);
                cs.Append("#define _CRTDBG_MAP_ALLOC"+cl);
                cs.Append("#include <math.h>"+cl);
                cs.Append("#include <winerror.h>"+cl);
                cs.Append("#include <stdlib.h>"+cl);
                cs.Append("#include <stdio.h>"+cl);
                cs.Append("#include <stddef.h>"+cl);
                cs.Append("#include <string.h>"+cl);
                if (this.WinSock == 1)
                {
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:LibraryGenerator.cs


示例3: AddLicense

 private void AddLicense(CodeProcessor cs,string filename)
 {
     string l = License;
     l = l.Replace("<FILE>",filename);
     cs.Append(l);
 }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:6,代码来源:LibraryGenerator.cs


示例4: BuildDeviceStructs

        protected static void BuildDeviceStructs(CodeProcessor cs, UPnPDevice d)
        {
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                BuildDeviceStructs(cs,ed);
            }
            cs.Append("struct UPnP_Device_"+d.User2.ToString()+cs.NewLine);
            cs.Append("{"+cs.NewLine);
            foreach(UPnPService s in d.Services)
            {
                cs.Append("	struct UPnP_Service_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+" *"+((ServiceGenerator.ServiceConfiguration)s.User).Name+";"+cs.NewLine);
            }
            cs.Append(cs.NewLine);
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                cs.Append("	struct UPnP_Device_"+ed.User2.ToString()+" *UPnP_Device_"+ed.User2.ToString()+";"+cs.NewLine);
            }
            cs.Append("	const char *FriendlyName;"+cs.NewLine);
            if (d.ParentDevice==null)
            {
                cs.Append("	const char *UDN;"+cs.NewLine);
                cs.Append("	const char *Serial;"+cs.NewLine);
            }
            cs.Append(" const char *Manufacturer;"+cs.NewLine);
            cs.Append(" const char *ManufacturerURL;"+cs.NewLine);
            cs.Append(" const char *ModelDescription;"+cs.NewLine);
            cs.Append(" const char *ModelName;"+cs.NewLine);
            cs.Append(" const char *ModelNumber;"+cs.NewLine);
            cs.Append(" const char *ModelURL;"+cs.NewLine);
            cs.Append("	const char *ProductCode;"+cs.NewLine);

            UPnPDevice[] embeddedDevices = d.EmbeddedDevices;
            UPnPService[] services = d.Services;

            d.EmbeddedDevices = new UPnPDevice[0];
            d.Services = new UPnPService[0];

            byte[] xml;
            if (d.Root)
            {
                xml = d.GetRootDeviceXML(null);
            }
            else
            {
                xml = (byte[])(new UPnPDebugObject(d)).InvokeNonStaticMethod("GetRootDeviceXML",new object[1]{null});
            }
            UTF8Encoding U = new UTF8Encoding();
            string xmlString = U.GetString(xml);
            string stringX;
            int stringXLen;
            InjectCompressedString(out stringX,out stringXLen,xmlString,cs.NewLine);
            d.EmbeddedDevices = embeddedDevices;
            d.Services = services;

            cs.Append("	char Reserved["+stringXLen.ToString()+"];"+cs.NewLine);
            cs.Append("	int ReservedXL;"+cs.NewLine);
            cs.Append("	int ReservedUXL;"+cs.NewLine);

            cs.Append("	void *User;"+cs.NewLine);
            if (d.ParentDevice==null)
            {
                cs.Append("	void *MicrostackToken;"+cs.NewLine);
            }
            cs.Append("};"+cs.NewLine);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:65,代码来源:DeviceObjectGenerator.cs


示例5: BuildStateVariableStructs

        protected static void BuildStateVariableStructs(CodeProcessor cs, UPnPDevice d)
        {
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                BuildStateVariableStructs(cs,ed);
            }
            foreach(UPnPService s in d.Services)
            {
                string stringX;
                int stringXLen;
                StringBuilder sb = new StringBuilder();
                StringWriter SW = new StringWriter(sb);
                XmlTextWriter X = new XmlTextWriter(SW);

                foreach(UPnPStateVariable v in s.GetStateVariables())
                {
                    UPnPDebugObject dobj = new UPnPDebugObject(v);
                    dobj.InvokeNonStaticMethod("GetStateVariableXML",new object[1]{X});
                }
                InjectCompressedString(out stringX,out stringXLen,sb.ToString(),cs.NewLine);

                cs.Append("struct UPnP_StateVariableTable_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+cs.NewLine);
                cs.Append("{"+cs.NewLine);
                cs.Append("	char Reserved["+stringXLen.ToString()+"];"+cs.NewLine);
                cs.Append("	int ReservedXL;"+cs.NewLine);
                cs.Append("	int ReservedUXL;"+cs.NewLine);
                cs.Append("};"+cs.NewLine);

                foreach(UPnPStateVariable v in s.GetStateVariables())
                {
                    cs.Append("struct UPnP_StateVariable_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+"_"+v.Name+cs.NewLine);
                    cs.Append("{"+cs.NewLine);
                    cs.Append("	int Reserved1;"+cs.NewLine);
                    cs.Append("	int Reserved1L;"+cs.NewLine);
                    if (v.AllowedStringValues!=null)
                    {
                        cs.Append("	int Reserved2;"+cs.NewLine);
                        cs.Append("	int Reserved2L;"+cs.NewLine);
                        cs.Append("	int Reserved3;"+cs.NewLine);
                        cs.Append("	int Reserved3L;"+cs.NewLine);
                        cs.Append("	char *AllowedValues[UPnP_StateVariable_AllowedValues_MAX];"+cs.NewLine);
                    }
                    if (v.Minimum!=null || v.Maximum!=null)
                    {
                        cs.Append("	int Reserved4;"+cs.NewLine);
                        cs.Append("	int Reserved4L;"+cs.NewLine);
                        cs.Append("	int Reserved5;"+cs.NewLine);
                        cs.Append("	int Reserved5L;"+cs.NewLine);
                        cs.Append("	char *MinMaxStep[3];"+cs.NewLine);
                    }
                    if (v.DefaultValue!=null)
                    {
                        cs.Append("	int Reserved6;"+cs.NewLine);
                        cs.Append("	int Reserved6L;"+cs.NewLine);
                        cs.Append("	int Reserved7;"+cs.NewLine);
                        cs.Append("	int Reserved7L;"+cs.NewLine);
                        cs.Append("	char *DefaultValue;"+cs.NewLine);
                    }
                    cs.Append("	int Reserved8;"+cs.NewLine);
                    cs.Append("	int Reserved8L;"+cs.NewLine);
                    cs.Append("};"+cs.NewLine);
                }
            }
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:64,代码来源:DeviceObjectGenerator.cs


示例6: GetDeviceObjectsString

        public static string GetDeviceObjectsString(UPnPDevice d)
        {
            CodeProcessor cs = new CodeProcessor(new StringBuilder(),false);
            cs.NewLine = "\r\n";

            //
            // Calculate the size to initialize "UPnP_StateVariable_AllowedValues_MAX"
            //
            int max = CalculateMaxAllowedValues(d,0);

            if (max!=0)
            {
                ++max;
                cs.Append("#define UPnP_StateVariable_AllowedValues_MAX "+max+cs.NewLine);
            }

            BuildStateVariableStructs(cs,d);
            BuildActionStructs(cs,d);
            BuildServiceStructs(cs,d);
            BuildDeviceStructs(cs,d);

            return(cs.ToString());
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:23,代码来源:DeviceObjectGenerator.cs


示例7: InjectBytes

        public static void InjectBytes(out string byteString, byte[] inVal, string newLine, bool withTypeCast)
        {
            CodeProcessor cs = new CodeProcessor(new StringBuilder(),false);
            cs.NewLine = newLine;

            cs.Append("{"+cs.NewLine);

            bool _first = true;
            int _ctr=0;
            foreach(byte b in inVal)
            {
                if (_first==false)
                {
                    cs.Append(",");
                }
                else
                {
                    _first = false;
                }
                string hx = b.ToString("X");
                if (withTypeCast)
                {
                    cs.Append("(char)");
                }
                cs.Append("0x");

                if (hx.Length==1){cs.Append("0");}
                cs.Append(hx);

                ++_ctr;
                if (_ctr%(withTypeCast?10:20)==0)
                {
                    cs.Append(cs.NewLine);
                }
            }
            cs.Append(cs.NewLine+"}");

            byteString = cs.ToString();
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:39,代码来源:DeviceObjectGenerator.cs


示例8: CreateMicroStack_Device_Values

 private void CreateMicroStack_Device_Values(CodeProcessor cs, UPnPDevice d)
 {
     cs.Append("\"" + (string)FriendlyNameTable[d] + "\", ");
     foreach (UPnPDevice dx in d.EmbeddedDevices)
     {
         CreateMicroStack_Device_Values(cs, dx);
     }
 }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:8,代码来源:EmbeddedCGenerator.cs


示例9: TypeCheckBoolean

 private void TypeCheckBoolean(CodeProcessor cs, UPnPArgument args)
 {
     cs.Append("	OK=0;" + cl);
     cs.Append("	if (p_" + args.Name + "Length == 4)" + cl);
     cs.Append("	{" + cl);
     cs.Append("		if (strncasecmp(p_" + args.Name + ",\"true\",4) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			_" + args.Name + " = 1;" + cl);
     cs.Append("		}" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (p_" + args.Name + "Length == 5)" + cl);
     cs.Append("	{" + cl);
     cs.Append("		if (strncasecmp(p_" + args.Name + ",\"false\",5) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			_" + args.Name + " = 0;" + cl);
     cs.Append("		}" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (p_" + args.Name + "Length == 1)" + cl);
     cs.Append("	{" + cl);
     cs.Append("		if (memcmp(p_" + args.Name + ",\"0\",1) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			_" + args.Name + " = 0;" + cl);
     cs.Append("		}" + cl);
     cs.Append("		if (memcmp(p_" + args.Name + ",\"1\",1) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			_" + args.Name + " = 1;" + cl);
     cs.Append("		}" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (OK == 0)" + cl);
     cs.Append("	{" + cl);
     if (Configuration.ExplicitErrorEncoding == true)
     {
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject, 402, \"Argument[" + args.Name + "] illegal value\");" + cl);
     }
     else
     {
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject, 402, \"Illegal value\");" + cl);
     }
     cs.Append("		return;" + cl);
     cs.Append("	}" + cl);
 }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:45,代码来源:EmbeddedCGenerator.cs


示例10: Build_TypeCheckUnsignedIntegral

 private void Build_TypeCheckUnsignedIntegral(CodeProcessor cs)
 {
     cs.Define("int " + pc_methodPrefixDef + "TypeCheckUnsignedIntegral(char* inVar, int inVarLength, unsigned long MinVal, unsigned long MaxVal, void *outVar, char *varName,struct HTTPReaderObject *ReaderObject)");
     cs.Append("{" + cl);
     cs.Append("	unsigned long TempULong;" + cl);
     cs.Append("	int OK = 0;" + cl);
     cs.Append("	char *msg;" + cl);
     cs.Append("	if (" + pc_methodLibPrefix + "GetULong(inVar, inVarLength, &TempULong)!=0)" + cl);
     cs.Append("	{" + cl);
     cs.Append("		OK=-1;" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (!(TempULong >= MinVal && TempULong <= MaxVal))" + cl);
     cs.Append("	{" + cl);
     cs.Append("		OK=-2;" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (OK==-1)" + cl);
     cs.Append("	{" + cl);
     if (Configuration.ExplicitErrorEncoding == true)
     {
         cs.Append("		if ((msg = (char*)malloc(25 + (int)strlen(varName))) == NULL) ILIBCRITICALEXIT(254);" + cl);
         cs.Append("		snprintf(msg, 25 + (int)strlen(varName), \"Argument[%s] illegal value\", varName);" + cl);
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject, 402, msg);" + cl);
         cs.Append("		free(msg);" + cl);
     }
     else
     {
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject,402,\"Illegal value\");" + cl);
     }
     cs.Append("		return(-1);" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (OK==-2)" + cl);
     cs.Append("	{" + cl);
     if (Configuration.ExplicitErrorEncoding == true)
     {
         cs.Append("		if ((msg = (char*)malloc(25 + (int)strlen(varName))) == NULL) ILIBCRITICALEXIT(254);" + cl);
         cs.Append("		snprintf(msg, 25 + (int)strlen(varName), \"Argument[%s] out of range\", varName);" + cl);
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject, 402, msg);" + cl);
         cs.Append("		free(msg);" + cl);
     }
     else
     {
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject, 402, \"Illegal value\");" + cl);
     }
     cs.Append("		return(-1);" + cl);
     cs.Append("	}" + cl);
     cs.Append("	*((unsigned long*)outVar) = TempULong;" + cl);
     cs.Append("	return(0);" + cl);
     cs.Append("}" + cl);
 }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:49,代码来源:EmbeddedCGenerator.cs


示例11: CreateMicroStackDef_Device

        private void CreateMicroStackDef_Device(CodeProcessor cs, UPnPDevice d, ref int counter)
        {
            ++counter;

            cs.Append("const char *FriendlyName" + counter.ToString() + ", ");
            foreach (UPnPDevice dx in d.EmbeddedDevices)
            {
                CreateMicroStackDef_Device(cs, dx, ref counter);
            }
        }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:10,代码来源:EmbeddedCGenerator.cs


示例12: Build_TypeCheckString

        private void Build_TypeCheckString(CodeProcessor cs, Hashtable serviceNames)
        {
            SortedList SL = new SortedList();
            IDictionaryEnumerator en = serviceNames.GetEnumerator();

            while (en.MoveNext())
            {
                SL[en.Value] = en.Key;
            }
            en = SL.GetEnumerator();

            cs.Define("int " + pc_methodPrefixDef + "TypeCheckString(char* inVar, int inVarLength, char* ServiceName, char* StateVariable, char** outVar, int* outVarLength, char* varName, struct HTTPReaderObject *ReaderObject)");
            cs.Append("{" + cl);
            cs.Append("	int OK = 0;" + cl);
            cs.Append("	char* msg;" + cl);
            while (en.MoveNext())
            {
                UPnPService S = (UPnPService)en.Value;
                string key = (string)en.Key;

                bool Needed = false;
                foreach (UPnPStateVariable V in S.GetStateVariables())
                {
                    if (V.AllowedStringValues != null)
                    {
                        Needed = true;
                        break;
                    }
                }

                if (Needed)
                {
                    cs.Append("	if (strncmp(ServiceName,\"" + key + "\"," + key.Length.ToString() + ") == 0)" + cl);
                    cs.Append("	{" + cl);
                    foreach (UPnPStateVariable V in S.GetStateVariables())
                    {
                        if (V.AllowedStringValues != null)
                        {
                            cs.Append("		if (strncmp(StateVariable,\"" + V.Name + "\"," + V.Name.Length.ToString() + ") == 0)" + cl);
                            cs.Append("		{" + cl);
                            cs.Append("			OK = -1;" + cl);
                            bool first = true;
                            foreach (string AllowedString in V.AllowedStringValues)
                            {
                                if (first == false) cs.Append("else ");
                                first = false;
                                cs.Append("			if (inVarLengt h== " + AllowedString.Length.ToString() + ")" + cl);
                                cs.Append("			{" + cl);
                                cs.Append("				if (memcmp(inVar,\"" + AllowedString + "\"," + AllowedString.Length.ToString() + ") == 0) {OK = 0;}" + cl);
                                cs.Append("			}" + cl);
                            }
                            cs.Append("			if (OK != 0)" + cl);
                            cs.Append("			{" + cl);
                            if (Configuration.ExplicitErrorEncoding == true)
                            {
                                cs.Append("				if ((msg = (char*)malloc(65)) == NULL) ILIBCRITICALEXIT(254);" + cl);
                                cs.Append("				snprintf(msg, 65, \"Argument[%s] contains a value that is not in AllowedValueList\", varName);" + cl);
                                cs.Append("				" + pc_methodPrefix + "Response_Error(ReaderObject, 402, msg);" + cl);
                                cs.Append("				free(msg);" + cl);
                            }
                            else
                            {
                                cs.Append("				" + pc_methodPrefix + "Response_Error(ReaderObject, 402, \"Illegal value\");" + cl);
                            }
                            cs.Append("				return -1;" + cl);
                            cs.Append("			}" + cl);
                            cs.Append("			*outVar = inVar;" + cl);
                            cs.Append("			*outVarLength = inVarLength;" + cl);
                            cs.Append("			return(0);" + cl);
                            cs.Append("		}" + cl);
                        }
                    }
                    cs.Append("	}" + cl);
                }
            }
            cs.Append("}" + cl);
        }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:77,代码来源:EmbeddedCGenerator.cs


示例13: Build_TypeCheckBoolean

 private void Build_TypeCheckBoolean(CodeProcessor cs)
 {
     cs.Define("int " + pc_methodPrefixDef + "TypeCheckBoolean(char *inVar, int inVarLength, int* BoolValue, char* varName, struct HTTPReaderObject *ReaderObject)");
     cs.Append("{" + cl);
     cs.Append("	int OK = 0;" + cl);
     cs.Append("	char* msg;" + cl);
     cs.Append("	if (inVarLength == 4)" + cl);
     cs.Append("	{" + cl);
     cs.Append("		if (strncasecmp(inVar, \"true\", 4) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			*BoolValue = 1;" + cl);
     cs.Append("		}" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (inVarLength == 5)" + cl);
     cs.Append("	{" + cl);
     cs.Append("		if (strncasecmp(inVar, \"false\", 5) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			*BoolValue = 0;" + cl);
     cs.Append("		}" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (inVarLength==1)" + cl);
     cs.Append("	{" + cl);
     cs.Append("		if (memcmp(inVar, \"0\", 1) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			*BoolValue = 0;" + cl);
     cs.Append("		}" + cl);
     cs.Append("		if (memcmp(inVar, \"1\", 1) == 0)" + cl);
     cs.Append("		{" + cl);
     cs.Append("			OK = 1;" + cl);
     cs.Append("			*BoolValue = 1;" + cl);
     cs.Append("		}" + cl);
     cs.Append("	}" + cl);
     cs.Append("	if (OK == 0)" + cl);
     cs.Append("	{" + cl);
     if (Configuration.ExplicitErrorEncoding == true)
     {
         cs.Append("		if ((msg = (char*)malloc(25 + (int)strlen(varName))) == NULL) ILIBCRITICALEXIT(254);" + cl);
         cs.Append("		snprintf(msg, 25 + (int)strlen(varName), \"Argument[%s] illegal value\", varName);" + cl);
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject, 402, msg);" + cl);
         cs.Append("		free(msg);" + cl);
     }
     else
     {
         cs.Append("		" + pc_methodPrefix + "Response_Error(ReaderObject, 402, \"Illegal value\");" + cl);
     }
     cs.Append("		return -1;" + cl);
     cs.Append("	}" + cl);
     cs.Append("	else" + cl);
     cs.Append("	{" + cl);
     cs.Append("		return 0;" + cl);
     cs.Append("	}" + cl);
     cs.Append("}" + cl);
 }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:56,代码来源:EmbeddedCGenerator.cs


示例14: Build_SubscribeEvents_Device

        private string Build_SubscribeEvents_Device(string first, CodeProcessor cs, UPnPDevice device, Hashtable serviceNames)
        {
            foreach (UPnPService service in device.Services)
            {
                bool HasEvent = false;
                foreach (UPnPStateVariable sv in service.GetStateVariables())
                {
                    if (sv.SendEvent)
                    {
                        HasEvent = true;
                        break;
                    }
                }

                if (HasEvent)
                {
                    UPnPDebugObject obj = new UPnPDebugObject(service);
                    string name = (string)obj.GetField("__eventurl");
                    cs.Append(first + " if (pathlength==" + (name.Length + 1).ToString() + " && memcmp(path+1,\"" + name + "\"," + name.Length.ToString() + ")==0)" + cl);
                    cs.Append("	{" + cl);

                    cs.Append("		" + pc_methodPrefix + "TryToSubscribe(\"" + (string)serviceNames[service] + "\",TimeoutVal,URL,URLLength,session);" + cl);

                    cs.Append("	}" + cl);
                    first = "else";
                }
            }

            foreach (UPnPDevice d in device.EmbeddedDevices)
            {
                first = Build_SubscribeEvents_Device(first, cs, d, serviceNames);
            }
            return (first);
        }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:34,代码来源:EmbeddedCGenerator.cs


示例15: PopulateStateVariableStructs

        protected static void PopulateStateVariableStructs(CodeProcessor cs, UPnPDevice d, Hashtable VarTable)
        {
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                PopulateStateVariableStructs(cs,ed,VarTable);
            }
            foreach(UPnPService s in d.Services)
            {
                cs.Append("struct UPnP_StateVariableTable_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+" UPnP_StateVariableTable_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+"_Impl = "+cs.NewLine);
                cs.Append("{"+cs.NewLine);
                string stringX;
                int stringXLen;
                StringBuilder sb = new StringBuilder();
                StringWriter SW = new StringWriter(sb);
                XmlTextWriter X = new XmlTextWriter(SW);

                foreach(UPnPStateVariable v in s.GetStateVariables())
                {
                    UPnPDebugObject dobj = new UPnPDebugObject(v);
                    dobj.InvokeNonStaticMethod("GetStateVariableXML",new object[1]{X});
                }
                X.Flush();
                InjectCompressedString(out stringX,out stringXLen,sb.ToString(),cs.NewLine);
                cs.Append("	"+stringX+","+cs.NewLine);
                cs.Append("	"+stringXLen.ToString()+","+cs.NewLine);
                cs.Append("	"+sb.Length.ToString()+cs.NewLine);
                cs.Append("};"+cs.NewLine);

                foreach(UPnPStateVariable v in s.GetStateVariables())
                {
                    Hashtable t = (Hashtable)VarTable[s];
                    int startingIndex = (int)((object[])t[v])[0];
                    string varString = (string)((object[])t[v])[2];

                    cs.Append("struct UPnP_StateVariable_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+"_"+v.Name+" UPnP_StateVariable_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+"_"+v.Name+"_Impl = "+cs.NewLine);
                    cs.Append("{"+cs.NewLine);
                    cs.Append("	"+startingIndex.ToString()+","+cs.NewLine); // Start Index
                    cs.Append("	"+(varString.IndexOf("</dataType>")+11).ToString()+","+cs.NewLine);

                    if (v.AllowedStringValues!=null)
                    {
                        int avlen=0;
                        foreach(string avs in v.AllowedStringValues)
                        {
                            avlen += avs.Length;
                        }
                        cs.Append("	"+(varString.IndexOf("<allowedValueList>")+startingIndex).ToString()+","+cs.NewLine); // Start of Allowed Value List
                        cs.Append("	18,"+cs.NewLine); // Length of allowedValueList
                        cs.Append("	"+(varString.IndexOf("</allowedValueList>")+startingIndex).ToString()+","+cs.NewLine); // Start of endTag
                        cs.Append("	19,"+cs.NewLine); // Length of end tag
                        cs.Append("	{");
                        foreach(string av in v.AllowedStringValues)
                        {
                            cs.Append("\""+av+"\",");
                        }
                        cs.Append("NULL");
                        cs.Append("}");
                    }
                    if (v.Minimum!=null || v.Maximum!=null)
                    {
                        if (v.AllowedStringValues!=null)
                        {
                            cs.Append(","+cs.NewLine);
                        }

                        cs.Append("	"+(startingIndex+varString.IndexOf("<allowedValueRange>")).ToString()+","+cs.NewLine);
                        cs.Append("	19,"+cs.NewLine);
                        cs.Append("	"+(startingIndex+varString.IndexOf("</allowedValueRange>")).ToString()+","+cs.NewLine);
                        cs.Append("	20,"+cs.NewLine);
                        cs.Append("	{");
                        if (v.Minimum!=null)
                        {
                            cs.Append("\""+v.Minimum.ToString()+"\",");
                        }
                        else
                        {
                            cs.Append("NULL,");
                        }
                        if (v.Maximum!=null)
                        {
                            cs.Append("\""+v.Maximum.ToString()+"\",");
                        }
                        else
                        {
                            cs.Append("NULL,");
                        }
                        if (v.Step!=null)
                        {
                            cs.Append("\""+v.Step.ToString()+"\"");
                        }
                        else
                        {
                            cs.Append("NULL");
                        }
                        cs.Append("}");
                    }
                    if (v.DefaultValue!=null)
                    {
                        if (v.AllowedStringValues!=null || v.Maximum!=null || v.Maximum!=null)
                        {
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:DeviceObjectGenerator.cs


示例16: TypeCheckDateTime

 private void TypeCheckDateTime(CodeProcessor cs, UPnPArgument args)
 {
     cs.Append("	p_" + args.Name + "[p_" + args.Name + "Length]=0;" + cl);
     cs.Append("	_" + args.Name + " = " + this.pc_methodLibPrefix + "Time_Parse(p_" + args.Name + ");" + cl);
 }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:5,代码来源:EmbeddedCGenerator.cs


示例17: GetCPlusPlusAbstraction_H

        public static string GetCPlusPlusAbstraction_H(UPnPDevice[] devices)
        {
            string WC = SourceCodeRepository.GetCPlusPlus_Template_H("UPnP");
            string WC2;
            CodeProcessor sb = new CodeProcessor(new StringBuilder(),false);
            bool ok = false;
            bool CPok = false;

            foreach(UPnPDevice d in devices)
            {
                if ((( 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeType类代码示例发布时间:2022-05-24
下一篇:
C# CodeNamespace类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap