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


C# CodeProcessor.Append方法代码示例

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


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

示例1: Build_DispatchMethods

        private void Build_DispatchMethods(CodeProcessor cs, Hashtable serviceNames)
        {
            SortedList SL = new SortedList();

            IDictionaryEnumerator en = serviceNames.GetEnumerator();
            UPnPService service;
            string name;

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

            en = SL.GetEnumerator();

            while (en.MoveNext())
            {
                int numArgs = 0;
                service = (UPnPService)en.Value;
                name = (string)en.Key;
                foreach (UPnPAction action in service.Actions)
                {
                    numArgs = 0;
                    foreach (UPnPArgument args in action.ArgumentList)
                    {
                        if (args.Direction == "in") { ++numArgs; }
                    }

                    // Define a macro version
                    if (numArgs == 0)
                    {
                        cs.Define("#define " + pc_methodPrefixDef + "Dispatch_" + name + "_" + action.Name + "(buffer,offset,bufferLength, session)\\");
                        cs.Append("{\\" + cl);
                        if (name != "DeviceSecurity")
                        {
                            if (Configuration.EXTERN_Callbacks == false)
                            {
                                cs.Append("	if (" + pc_methodPrefix + "FP_" + name + "_" + action.Name + " == NULL)\\" + cl);
                                cs.Append("		" + pc_methodPrefix + "Response_Error(session,501,\"No Function Handler\");\\" + cl);
                                cs.Append("	else\\" + cl);
                                cs.Append("		" + pc_methodPrefix + "FP_" + name + "_" + action.Name + "((void*)session);\\" + cl);
                            }
                            else
                            {
                                cs.Append("	" + pc_methodPrefix + name + "_" + action.Name + "((void*)session);\\" + cl);
                            }
                        }
                        else
                        {
                            cs.Append("	" + pc_methodLibPrefix + name + "_" + action.Name + "((void*)session);\\" + cl);
                        }
                        cs.Append("}" + cl);
                        cs.Append(cl);
                    }

                    if (numArgs > 0)
                    {
                        cs.Define("void " + pc_methodPrefixDef + "Dispatch_" + name + "_" + action.Name + "(char *buffer, int offset, int bufferLength, struct " + this.pc_methodLibPrefix + "WebServer_Session *ReaderObject)");
                        cs.Append("{" + cl);

                        bool varlong = false;
                        bool varlongtemp = false;
                        bool varulong = false;
                        bool varulongtemp = false;
                        bool varuuri = false;
                        bool varok = false;
                        foreach (UPnPArgument args in action.ArgumentList)
                        {
                            if (args.Direction == "in")
                            {
                                varok = true;
                                switch (args.RelatedStateVar.GetNetType().ToString())
                                {
                                    case "System.Uri":
                                        varuuri = true;
                                        break;
                                    case "System.Byte":
                                    case "System.UInt16":
                                    case "System.UInt32":
                                        varulong = true;
                                        if (args.RelatedStateVar.Maximum != null || args.RelatedStateVar.Minimum != null)
                                        {
                                            varulongtemp = true;
                                        }
                                        break;
                                    case "System.SByte":
                                    case "System.Int16":
                                    case "System.Int32":
                                        varlong = true;
                                        if (args.RelatedStateVar.Maximum != null || args.RelatedStateVar.Minimum != null)
                                        {
                                            varlongtemp = true;
                                        }
                                        break;
                                    case "System.Boolean":
                                    case "System.Char":
                                    case "System.Single":
                                    case "System.Double":
                                    case "System.Byte[]":
                                    case "System.String":
//.........这里部分代码省略.........
开发者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: 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 (((ServiceGenerator.Configuration)d.User).ConfigType==ServiceGenerator.ConfigurationType.DEVICE)
                {
                    WC2 = GetCPlusPlusAbstraction_H_FriendDevice(WC,d);
                    WC = SourceCodeRepository.InsertTextBeforeTag(WC,"//{{{Manager_Friends_BEGIN}}}",WC2);

                    WC2 = SourceCodeRepository.GetTextBetweenTags(WC,"//{{{Manager_GetDevice_BEGIN}}}","//{{{Manager_GetDevice_END}}}");
                    WC2 = WC2.Replace("{{{DEVICE}}}","UPnP_Device_"+d.User2.ToString());
                    WC = SourceCodeRepository.InsertTextBeforeTag(WC,"//{{{Manager_GetDevice_BEGIN}}}",WC2);

                    WC2 = SourceCodeRepository.GetTextBetweenTags(WC,"//{{{Manager_Device_BEGIN}}}","//{{{Manager_Device_END}}}");
                    WC2 = WC2.Replace("{{{DEVICE}}}","UPnP_Device_"+d.User2.ToString());
                    WC = SourceCodeRepository.InsertTextBeforeTag(WC,"//{{{Manager_Device_BEGIN}}}",WC2);

                    WC = GetCPlusPlusAbstraction_H_Device(WC,d);
                    ok = true;
                }
                else
                {
                    WC2 = SourceCodeRepository.GetTextBetweenTags(WC,"//{{{Manager_SetControlPoint_BEGIN}}}","//{{{Manager_SetControlPoint_END}}}");
                    WC2 = WC2.Replace("{{{DEVICE}}}",d.User2.ToString());
                    WC = SourceCodeRepository.InsertTextBeforeTag(WC,"//{{{Manager_SetControlPoint_BEGIN}}}",WC2);

                    WC2 = SourceCodeRepository.GetTextBetweenTags(WC,"//{{{Manager_ProtectedCP_Stuff_BEGIN}}}","//{{{Manager_ProtectedCP_Stuff_END}}}");
                    WC2 = WC2.Replace("{{{DEVICE}}}",d.User2.ToString());
                    WC2 = WC2.Replace("{{{DEVICE_ID}}}",d.GetHashCode().ToString());
                    WC = SourceCodeRepository.InsertTextBeforeTag(WC,"//{{{Manager_ProtectedCP_Stuff_BEGIN}}}",WC2);

                    WC2 = GetCPlusPlusAbstraction_H_Device_CP(WC,d);
                    WC = SourceCodeRepository.InsertTextBeforeTag(WC,"//{{{BEGIN_CP_SERVICE}}}",WC2);
                    CPok = true;
                    ok = true;
                }
            }

            WC = SourceCodeRepository.RemoveAndClearTag("//{{{Manager_SetControlPoint_BEGIN}}}","//{{{Manager_SetControlPoint_END}}}",WC);
            WC = SourceCodeRepository.RemoveAndClearTag("//{{{Manager_ProtectedCP_Stuff_BEGIN}}}","//{{{Manager_ProtectedCP_Stuff_END}}}",WC);

            if (!CPok)
            {
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{ControlPoint_Begin}}}","//{{{ControlPoint_End}}}",WC);
            }
            else
            {
                WC = SourceCodeRepository.RemoveTag("//{{{ControlPoint_Begin}}}","//{{{ControlPoint_End}}}",WC);
            }

            if (ok)
            {
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{Device_Begin}}}","//{{{Device_End}}}",WC);
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{Service_Begin}}}","//{{{Service_End}}}",WC);
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{Manager_Friends_BEGIN}}}","//{{{Manager_Friends_END}}}",WC);
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{Manager_GetDevice_BEGIN}}}","{{{Manager_GetDevice_END}}}",WC);
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{Manager_Device_BEGIN}}}","//{{{Manager_Device_END}}}",WC);
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_CP_SERVICE}}}","//{{{END_CP_SERVICE}}}",WC);

                WC = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_EVENT_TYPEDEF}}}","//{{{END_EVENT_TYPEDEF}}}",WC);
                WC = SourceCodeRepository.RemoveAndClearTag("//{{{BEGIN_EVENT}}}","//{{{END_EVENT}}}",WC);
                sb.Append(WC);
            }
            return(sb.ToString());
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:71,代码来源: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: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: PopulateDeviceStructs

        protected static void PopulateDeviceStructs(CodeProcessor cs, UPnPDevice d)
        {
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                PopulateDeviceStructs(cs,ed);
            }
            cs.Append("struct UPnP_Device_"+d.User2.ToString()+" UPnP_Device_"+d.User2.ToString()+"_Impl = "+cs.NewLine);
            cs.Append("{"+cs.NewLine);
            foreach(UPnPService s in d.Services)
            {
                cs.Append("	&UPnP_Service_"+((ServiceGenerator.ServiceConfiguration)s.User).Name+"_Impl,"+cs.NewLine);
            }
            cs.Append(cs.NewLine);
            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                cs.Append("	&UPnP_Device_"+ed.User2.ToString()+"_Impl,"+cs.NewLine);
            }
            cs.Append("	NULL,"+cs.NewLine); // Friendly
            if (d.ParentDevice==null)
            {
                cs.Append("	NULL,"+cs.NewLine+"	NULL,"+cs.NewLine); //UDN, Serial
            }
            cs.Append(" NULL,"+cs.NewLine); //Manufacturer
            cs.Append(" NULL,"+cs.NewLine); //ManufacturerURL
            cs.Append(" NULL,"+cs.NewLine); //ModelDescription
            cs.Append(" NULL,"+cs.NewLine); //ModelName
            cs.Append(" NULL,"+cs.NewLine); //ModelNumber
            cs.Append(" NULL,"+cs.NewLine); //ModelURL
            cs.Append(" NULL,"+cs.NewLine); //Product Code

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

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

            string xmlString;

            if (d.ParentDevice==null)
                {byte[] xml;
                xml = d.GetRootDeviceXML(null);
                xmlString = (new UTF8Encoding()).GetString(xml);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                StringWriter SW = new StringWriter(sb);
                XmlTextWriter XDoc = new XmlTextWriter(SW);
                (new UPnPDebugObject(d)).InvokeNonStaticMethod("GetNonRootDeviceXML",new object[2]{null,XDoc});
                SW.Flush();
                xmlString = sb.ToString();
            }
            string stringX;
            int stringXLen;
            InjectCompressedString(out stringX,out stringXLen,xmlString,cs.NewLine);

            cs.Append("	"+stringX+","+cs.NewLine);
            cs.Append("	"+stringXLen.ToString()+","+cs.NewLine);
            cs.Append("	"+xmlString.Length.ToString()+","+cs.NewLine);
            if (d.ParentDevice==null)
            {
                cs.Append("	NULL,"+cs.NewLine);
            }
            cs.Append("	NULL"+cs.NewLine);
            cs.Append("};"+cs.NewLine);

            d.EmbeddedDevices = embeddedDevices;
            d.Services = services;
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:69,代码来源:DeviceObjectGenerator.cs


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