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


C# CodeProcessor.Comment方法代码示例

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


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

示例1: Build_UPnPHTTPClient

        public bool Build_UPnPHTTPClient(DirectoryInfo outputDirectory)
        {
            StreamWriter writer;

            if (this.Platform == PLATFORMS.POSIX)
            {
                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 UPnPHTTPClient.h */
            AddLicense(cs,pc_methodPrefix+"HTTPClient.h");

            cs.Append(cl);
            cs.Append("#ifndef __"+pc_methodPrefix+"HTTPClient__"+cl);
            cs.Append("#define __"+pc_methodPrefix+"HTTPClient__"+cl);
            cs.Append(cl);
            cs.Append("#define HTTP_SESSION_INTERRUPT_CHAIN 1"+cl);
            cs.Append("#define HTTP_SESSION_INTERRUPT_PEERRESET 2"+cl);
            cs.Append("#define HTTP_INTERRUPT_CHAIN 3"+cl);
            cs.Append("#define HTTP_DELETEREQUEST_INTERRUPT 4"+cl);

            cs.Append("#define "+pc_methodPrefix+"AddRequest_Direct(ClientModule, buffer, bufferlength,Destination, CallbackPtr, user, user2) "+pc_methodPrefix+"AddRequest_DirectEx(ClientModule, buffer, bufferlength,NULL,0,Destination, CallbackPtr, user, user2)"+cl);
            cs.Append(cl);
            cs.Comment("Forward Declaration");
            cs.Append("struct packetheader;"+cl+cl);

            cs.Append("void* "+pc_methodPrefix+"CreateHTTPClientModule(void *Chain, int MaxSockets);"+cl);
            cs.Append("void  "+pc_methodPrefix+"DestroyHTTPClientModule(void *ClientModule);"+cl);
            cs.Append(cl);
            cs.Append("char* "+pc_methodPrefix+"GetReceivingInterface(void* ReaderObject);"+cl);
            cs.Append("void  "+pc_methodPrefix+"AddRequest(void *ClientModule, struct packetheader *packet,struct sockaddr_in *Destination, void (*CallbackPtr)(void *reader, struct packetheader *header, int IsInterrupt,char* buffer, int *p_BeginPointer, int EndPointer, int done, void* user, void* user2), void* user, void* user2);"+cl);
            cs.Append("void  "+pc_methodPrefix+"AddRequest_DirectEx(void *ClientModule, char *buffer, int bufferlength,char *buffer2, int buffer2length,struct sockaddr_in *Destination, void (*CallbackPtr)(void *reader, struct packetheader *header, int IsInterrupt, char* buffer, int *p_BeginPointer, int EndPointer, int done, void* user, void* user2), void* user, void* user2);"+cl);
            cs.Append("void  "+pc_methodPrefix+"CloseRequest(void* ReaderObject);"+cl);
            cs.Append("void  "+pc_methodPrefix+"DeleteRequests(void *ClientModule, void *user1);"+cl);

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

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

            /* Build UPnPHTTPClient.c */
            cs = new CodeProcessor(new StringBuilder(),this.Language == LANGUAGES.CPP);
            if (this.Language == LANGUAGES.CPP)
            {
                AddLicense(cs,pc_methodPrefix+"HTTPClient.cpp");
            }
            else
            {
                AddLicense(cs,pc_methodPrefix+"HTTPClient.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)
                {
                    cs.Append("#include <winsock.h>"+cl);
                    cs.Append("#include <wininet.h>"+cl);
                }
                if (this.WinSock == 2)
                {
                    cs.Append("#include <winsock2.h>"+cl);
                    cs.Append("#include <ws2tcpip.h>"+cl);
                }
                if (this.SubTarget != SUBTARGETS.PPC2003)
                {
            //					cs.Append("#include <errno.h>"+cl);
                }
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:LibraryGenerator.cs

示例2: GenerateEx

        protected bool GenerateEx(UPnPDevice device, DirectoryInfo outputDirectory, Hashtable serviceNames)
        {
            string sampleService = "Sample";
            StreamWriter writer;
            ServiceNames = serviceNames;
            DText dt = new DText();
            dt.ATTRMARK = ":";
            dt[0] = device.DeviceURN;

            // *** Generate Main Code
            Log("Writing main stack module...");

            IDictionaryEnumerator en = serviceNames.GetEnumerator();
            while (en.MoveNext())
            {
                string servicename = (string)en.Value;
                sampleService = servicename;
                UPnPService service = (UPnPService)en.Key;
                string servicexml = new UTF8Encoding().GetString(service.GetSCPDXml());
                Log("Generating service class for " + servicename);
                OpenSource.UPnP.ServiceGenerator.GenerateCP("Cp" + servicename, nspace, outputDirectory.FullName + "\\Cp" + servicename + ".cs", service.ServiceURN, servicexml);
            }

            CodeProcessor cs = new CodeProcessor(new StringBuilder(), true);
            StringBuilder cs2;

            cs.Comment("UPnP .NET Framework Control Point Stack, Discovery Module");
            cs.Comment(VersionString);
            cs.Append(cl);
            cs.Append("using System;" + cl);
            cs.Append("using System.Net;" + cl);
            cs.Append("using OpenSource.UPnP;" + cl);
            cs.Append("using OpenSource.Utilities;" + cl);
            cs.Append("using " + nspace + ";" + cl);
            cs.Append(cl);
            cs.Append("namespace " + nspace + cl);
            cs.Append("{" + cl);
            cs.Append("	/// <summary>" + cl);
            cs.Append("	/// Summary description for " + dt[4] + "Discovery." + cl);
            cs.Append("	/// </summary>" + cl);
            cs.Append("	class " + dt[4] + "Discovery" + cl);
            cs.Append("	{" + cl);
            cs.Append("		private UPnPSmartControlPoint scp;" + cl);
            cs.Append("		private WeakEvent AddEvent = new WeakEvent();" + cl);
            cs.Append("		private WeakEvent RemoveEvent = new WeakEvent();" + cl);
            cs.Append(cl);
            cs.Append("		public delegate void DiscoveryHandler(" + dt[4] + "Discovery sender, UPnPDevice dev);" + cl);
            cs.Append("		public event DiscoveryHandler OnAddedDevice" + cl);
            cs.Append("		{" + cl);
            cs.Append("			add" + cl);
            cs.Append("			{" + cl);
            cs.Append("				AddEvent.Register(value);" + cl);
            cs.Append("			}" + cl);
            cs.Append("			remove" + cl);
            cs.Append("			{" + cl);
            cs.Append("				AddEvent.UnRegister(value);" + cl);
            cs.Append("			}" + cl);
            cs.Append("		}" + cl);
            cs.Append(cl);
            cs.Append("		public event DiscoveryHandler OnRemovedDevice" + cl);
            cs.Append("		{" + cl);
            cs.Append("			add" + cl);
            cs.Append("			{" + cl);
            cs.Append("				RemoveEvent.Register(value);" + cl);
            cs.Append("			}" + cl);
            cs.Append("			remove" + cl);
            cs.Append("			{" + cl);
            cs.Append("				RemoveEvent.UnRegister(value);" + cl);
            cs.Append("			}" + cl);
            cs.Append("		}" + cl);
            cs.Append(cl);
            cs.Append("		public " + dt[4] + "Discovery()" + cl);
            cs.Append("		{" + cl);
            cs.Append("		}" + cl);
            cs.Append(cl);
            cs.Append("		public void Start()" + cl);
            cs.Append("		{" + cl);
            cs.Append("			scp = new UPnPSmartControlPoint(new UPnPSmartControlPoint.DeviceHandler(OnAddSink), null ,\"" + device.DeviceURN + "\");" + cl);
            cs.Append("			scp.OnRemovedDevice += new UPnPSmartControlPoint.DeviceHandler(OnRemoveSink);" + cl);
            cs.Append("		}" + cl);
            cs.Append(cl);
            cs.Append("		public void ReScan()" + cl);
            cs.Append("		{" + cl);
            cs.Append("			scp.Rescan();" + cl);
            cs.Append("		}" + cl);
            cs.Append(cl);
            cs.Append("		public void UnicastSearch(IPAddress address)" + cl);
            cs.Append("		{" + cl);
            cs.Append("			scp.UnicastSearch(address);" + cl);
            cs.Append("		}" + cl);
            cs.Append(cl);
            cs.Append("		public void ForceDisposeDevice(UPnPDevice dev)" + cl);
            cs.Append("		{" + cl);
            cs.Append("			if (dev.ParentDevice != null)" + cl);
            cs.Append("			{" + cl);
            cs.Append("				ForceDisposeDevice(dev.ParentDevice);" + cl);
            cs.Append("			}" + cl);
            cs.Append("			else" + cl);
            cs.Append("			{" + cl);
            cs.Append("				scp.ForceDisposeDevice(dev);" + cl);
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:CPDotNetGenerator.cs

示例3: BuildComplexTypeParser_Header

 public static void BuildComplexTypeParser_Header(CodeProcessor cs, SortedList SortedServiceList, string pc_methodPrefix, string pc_methodLibPrefix)
 {
     cs.Append(cl);
     cs.Comment("Complex Type Parsers");
     IDictionaryEnumerator en = SortedServiceList.GetEnumerator();
     while (en.MoveNext())
     {
         UPnPService service = (UPnPService)en.Value;
         foreach (UPnPComplexType CT in service.GetComplexTypeList())
         {
             cs.Append("struct " + CT.Name_LOCAL + "* " + pc_methodPrefix + "Parse_" + CT.Name_LOCAL + "(struct " + pc_methodLibPrefix + "XMLNode *node);" + cl);
         }
     }
     cs.Append(cl);
 }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:15,代码来源:EmbeddedCGenerator.cs

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

示例5: BuildUPnPResponseHeaders

 private void BuildUPnPResponseHeaders(CodeProcessor cs, UPnPDevice device, Hashtable serviceNames)
 {
     foreach (UPnPService service in device.Services)
     {
         ServiceGenerator.ServiceConfiguration SConf = (ServiceGenerator.ServiceConfiguration)service.User;
         foreach (UPnPAction action in service.Actions)
         {
             cs.Append("void " + pc_methodPrefixDef + "Response_" + serviceNames[service] + "_" + action.Name + "(const UPnPSessionToken UPnPToken");
             /*
             if (action.HasReturnValue)
             {
                 cs.Append(", const " + ToCType(action.GetRetArg().RelatedStateVar.GetNetType().FullName) + " __ReturnValue");
                 if (action.GetRetArg().RelatedStateVar.GetNetType().FullName=="System.Byte[]")
                 {
                     cs.Append(", const int __ReturnValueLength");
                 }
             }
             */
             foreach (UPnPArgument arg in action.Arguments)
             {
                 if (arg.Direction == "out")
                 {
                     if (arg.RelatedStateVar.ComplexType == null)
                     {
                         // Simple Type
                         cs.Append(", const " + ToCType(arg.RelatedStateVar.GetNetType().ToString()) + " " + arg.Name);
                         if (arg.RelatedStateVar.GetNetType().FullName == "System.Byte[]")
                         {
                             cs.Append(", const int _" + arg.Name + "Length");
                         }
                     }
                     else
                     {
                         // Complex Type
                         cs.Append(", struct " + arg.RelatedStateVar.ComplexType.Name_LOCAL + " *" + arg.Name);
                     }
                 }
             }
             cs.Append(");" + cl);
         }
         bool NeedManualComment = false;
         foreach (UPnPAction action in service.Actions)
         {
             if (SConf.Actions_ManualEscape.Contains(action))
             {
                 // Manual Escape
                 NeedManualComment = true;
                 break;
             }
         }
         if (NeedManualComment)
         {
             cs.Append(cl);
             cs.Comment("The string parameters for the following response methods MUST be MANUALLY escaped");
             foreach (UPnPAction action in service.Actions)
             {
                 if (SConf.Actions_ManualEscape.Contains(action))
                 {
                     cs.Comment("void " + pc_methodPrefixDef + "Response_" + serviceNames[service] + "_" + action.Name);
                 }
             }
             cs.Append(cl);
         }
     }
     foreach (UPnPDevice d in device.EmbeddedDevices)
     {
         this.BuildUPnPResponseHeaders(cs, d, serviceNames);
     }
 }
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:69,代码来源:EmbeddedCGenerator.cs

示例6: Build_DispatchMethods


//.........这里部分代码省略.........
                                cs.Append("	int p_" + args.Name + "Length = 0;" + cl);
                                if (args.RelatedStateVar.ComplexType == null)
                                {
                                    cs.Append("	" + ToCType(args.RelatedStateVar.GetNetType().FullName) + " _" + args.Name + " = " + ToEmptyValue(args.RelatedStateVar.GetNetType().FullName) + ";" + cl);
                                    if (ToCType(args.RelatedStateVar.GetNetType().FullName) == "char*" || ToCType(args.RelatedStateVar.GetNetType().FullName) == "unsigned char*")
                                    {
                                        cs.Append("	int _" + args.Name + "Length;" + cl);
                                    }
                                }
                                else
                                {
                                    cs.Append(" struct " + args.RelatedStateVar.ComplexType.Name_LOCAL + " *_" + args.Name + "=NULL;" + cl);
                                }
                            }
                        }

                        //
                        // Setup the XML Parsing
                        //
                        cs.Append("	struct " + this.pc_methodLibPrefix + "XMLNode *xnode = " + this.pc_methodLibPrefix + "ParseXML(buffer, offset, bufferLength);" + cl);
                        cs.Append("	struct " + this.pc_methodLibPrefix + "XMLNode *root = xnode;" + cl);
                        foreach (UPnPArgument args in action.ArgumentList)
                        {
                            if (args.Direction == "in" && args.RelatedStateVar.ComplexType != null)
                            {
                                cs.Append("	struct " + this.pc_methodLibPrefix + "XMLNode *tnode, *tnode_root;" + cl);
                                cs.Append("	char* tempText;" + cl);
                                cs.Append("	int tempTextLength;" + cl);
                                break;
                            }
                        }
                        cs.Append("	if (" + this.pc_methodLibPrefix + "ProcessXMLNodeList(root)!=0)" + cl);
                        cs.Append("	{" + cl);
                        cs.Comment("The XML is not well formed!");
                        cs.Append("	" + this.pc_methodLibPrefix + "DestructXMLNodeList(root);" + cl);
                        cs.Append("	" + this.pc_methodPrefix + "Response_Error(ReaderObject, 501, \"Invalid XML\");" + cl);
                        cs.Append("	return;" + cl);
                        cs.Append("	}" + cl);

                        cs.Append("	while(xnode != NULL)" + cl);
                        cs.Append("	{" + cl);
                        cs.Append("		if (xnode->StartTag != 0 && xnode->NameLength == 8 && memcmp(xnode->Name, \"Envelope\", 8)==0)" + cl);
                        cs.Append("		{" + cl);
                        cs.Append("			// Envelope" + cl);
                        cs.Append("			xnode = xnode->Next;" + cl);
                        cs.Append("			while(xnode != NULL)" + cl);
                        cs.Append("			{" + cl);
                        cs.Append("				if (xnode->StartTag!=0 && xnode->NameLength == 4 && memcmp(xnode->Name, \"Body\", 4) == 0)" + cl);
                        cs.Append("				{" + cl);
                        cs.Append("					// Body" + cl);
                        cs.Append("					xnode = xnode->Next;" + cl);
                        cs.Append("					while(xnode != NULL)" + cl);
                        cs.Append("					{" + cl);
                        cs.Append("						if (xnode->StartTag != 0 && xnode->NameLength == " + action.Name.Length.ToString() + " && memcmp(xnode->Name, \"" + action.Name + "\"," + action.Name.Length.ToString() + ") == 0)" + cl);
                        cs.Append("						{" + cl);
                        cs.Append("							// Inside the interesting part of the SOAP" + cl);
                        cs.Append("							xnode = xnode->Next;" + cl);
                        cs.Append("							while(xnode != NULL)" + cl);
                        cs.Append("							{" + cl);

                        int argflag = 1;
                        string eLsE = "";
                        foreach (UPnPArgument arg in action.ArgumentList)
                        {
                            if (arg.Direction == "in")
                            {
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:67,代码来源:EmbeddedCGenerator.cs

示例7: BuildServiceDescriptions

        private void BuildServiceDescriptions(CodeProcessor cs, UPnPDevice device, Hashtable serviceNames)
        {
            UTF8Encoding U = new UTF8Encoding();
            Log("  Service description blocks.");
            string http_200_header;

            UPnPDevice root = device;
            while (root.ParentDevice != null)
            {
                root = root.ParentDevice;
            }

            if (!Configuration.HTTP_1dot1)
            {
                http_200_header = "HTTP/1.0 200  OK\r\nCONTENT-TYPE:  text/xml; charset=\"utf-8\"\r\nServer: " + UseSystem + ", UPnP/" + root.ArchitectureVersion + ", MicroStack/" + UseVersion + "\r\n";
            }
            else
            {
                http_200_header = "HTTP/1.1 200  OK\r\nCONTENT-TYPE:  text/xml; charset=\"utf-8\"\r\nServer: " + UseSystem + ", UPnP/" + root.ArchitectureVersion + ", MicroStack/" + UseVersion + "\r\n";
            }
            foreach (UPnPService service in device.Services)
            {
                string servicexml = new UTF8Encoding().GetString(service.GetSCPDXml());
                for (int i = 0; i < 40; i++) servicexml = servicexml.Replace("\r\n ", "\r\n");
                servicexml = servicexml.Replace("\r\n", "");
                string servicehttpresponse = http_200_header + "Content-Length: " + U.GetByteCount(servicexml).ToString() + "\r\n\r\n" + servicexml;

                cs.Comment(serviceNames[service].ToString());

                byte[] _sr = OpenSource.Utilities.StringCompressor.CompressString(servicehttpresponse);
                cs.Append("const int " + pc_methodPrefix + serviceNames[service] + "DescriptionLengthUX = " + U.GetByteCount(servicehttpresponse).ToString() + ";" + cl);
                cs.Append("const int " + pc_methodPrefix + serviceNames[service] + "DescriptionLength = " + (_sr.Length).ToString() + ";" + cl);
                cs.Append("const char " + pc_methodPrefix + serviceNames[service] + "Description[" + (_sr.Length).ToString() + "] = {" + cl);
                bool _first = true;
                int _ctr = 0;
                foreach (byte b in _sr)
                {
                    if (_first == false)
                    {
                        cs.Append(",");
                    }
                    else
                    {
                        _first = false;
                    }
                    string hx = b.ToString("X");
                    cs.Append("0x");
                    if (hx.Length == 1) { cs.Append("0"); }
                    cs.Append(hx);

                    ++_ctr;
                    if (_ctr % 20 == 0)
                    {
                        cs.Append("\r\n");
                    }
                }
                cs.Append("};" + cl);
            }

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

示例8: BuildUPnPResponse


//.........这里部分代码省略.........
                                    cs.Append("	char *" + arg.Name + " = (char*)malloc(1+" + this.pc_methodLibPrefix + "XmlEscapeLength(unescaped_" + arg.Name + "));" + cl);
                                }
                            }
                            else
                            {
                                //Complex
                                cs.Append("	char *" + arg.Name + ";" + cl);
                            }
                        }
                    }
                    cs.Append(cl);
                    foreach (UPnPArgument arg in action.Arguments)
                    {
                        if (arg.RelatedStateVar.ComplexType == null)
                        {
                            // If this is a simple string, we need to escape it
                            if (arg.Direction == "out" && arg.RelatedStateVar.GetNetType() == typeof(string) && !SConf.Actions_ManualEscape.Contains(action))
                            {
                                cs.Append("	" + this.pc_methodLibPrefix + "XmlEscape(" + arg.Name + ", unescaped_" + arg.Name + ");" + cl);
                            }
                        }
                    }
                    bool needSpecial = false;
                    foreach (UPnPArgument arg in action.Arguments)
                    {
                        if (arg.RelatedStateVar.ComplexType != null)
                        {
                            needSpecial = true;
                            break;
                        }
                    }
                    if (needSpecial)
                    {
                        cs.Comment("For Complex Types, we need to:");
                        cs.Comment("1.) Serialize the XML structure");
                        cs.Comment("2.) Escape the serialization for legacy CPs");
                        cs.Append(cl);
                        foreach (UPnPArgument a in action.Arguments)
                        {
                            if (a.RelatedStateVar.ComplexType != null)
                            {
                                cs.Append("	" + a.Name + "= " + this.pc_methodPrefix + "Serialize_" + a.RelatedStateVar.ComplexType.Name_LOCAL + "(_" + a.Name + ");" + cl);
                            }
                        }
                        cs.Append("	if (((struct ILibWebServer_Session*)UPnPToken)->Reserved9 == 0)" + cl);
                        cs.Append("	{" + cl);
                        cs.Comment("Serialization for Legacy CP");
                        foreach (UPnPArgument a in action.Arguments)
                        {
                            if (a.RelatedStateVar.ComplexType != null)
                            {
                                cs.Append(cl);
                                cs.Append("	if ((tempString = (char*)malloc(1+" + this.pc_methodLibPrefix + "XmlEscapeLength(" + a.Name + "))) == NULL) ILIBCRITICALEXIT(254);" + cl);
                                cs.Append("	tempString[" + this.pc_methodLibPrefix + "XmlEscape(tempString, " + a.Name + ")] = 0;" + cl);
                                cs.Append("	free(" + a.Name + ");" + cl);
                                cs.Append("	" + a.Name + " = tempString;" + cl);
                            }
                        }
                        cs.Append("	}" + cl);
                    }

                    string soap_invokeResponse = "";
                    int soap_size = 1;
                    string soap_size_str = "";
                    foreach (UPnPArgument arg in action.Arguments)
                    {
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:67,代码来源:EmbeddedCGenerator.cs

示例9: GenerateEx


//.........这里部分代码省略.........
            en.Reset();
            while (en.MoveNext())
            {
                UPnPService service = (UPnPService)en.Value;
                if (Configuration.EXTERN_Callbacks == true || serviceNames[service].ToString() == "DeviceSecurity")
                {
                    foreach (UPnPAction action in service.Actions)
                    {
                        if (serviceNames[service].ToString() == "DeviceSecurity")
                        {
                            cs.Append("extern void " + pc_methodLibPrefix + serviceNames[service] + "_" + action.Name + "(void* upnptoken");
                        }
                        else
                        {
                            cs.Append("extern void " + pc_methodPrefix + serviceNames[service] + "_" + action.Name + "(void* upnptoken");
                        }
                        foreach (UPnPArgument arg in action.Arguments)
                        {
                            if (arg.Direction == "in")
                            {
                                cs.Append("," + ToCType(arg.RelatedStateVar.GetNetType().ToString()) + " " + arg.Name);
                                if (arg.RelatedStateVar.GetNetType().FullName == "System.Byte[]")
                                {
                                    cs.Append(",int _" + arg.Name + "Length");
                                }
                            }
                        }
                        cs.Append(");" + cl);
                    }
                }
            }
            if (Configuration.EXTERN_Callbacks == false)
            {
                cs.Comment("UPnP Set Function Pointers Methods");
                cs.Append("extern void (*" + pc_methodPrefixDef + "FP_PresentationPage) (void* upnptoken,struct packetheader *packet);" + cl);
                BuildFunctionPointerHeaders(cs, device, serviceNames);
                cs.Append(cl);
            }
            else
            {
                cs.Append("extern void " + pc_methodPrefix + "PresentationRequest(void* upnptoken, struct packetheader *packet);" + cl);
            }
            WS = WS.Replace("//{{{UPnP_Set_Function_Pointer_Methods}}}", cs.ToString());
            #endregion
            #region Invocation Response Methods
            cs = new CodeProcessor(new StringBuilder(), this.Language == LANGUAGES.CPP);

            cs.Comment("Invocation Response Methods");
            cs.Append("void " + pc_methodPrefixDef + "Response_Error(const UPnPSessionToken UPnPToken, const int ErrorCode, const char* ErrorMsg);" + cl);
            cs.Append("void " + pc_methodPrefixDef + "ResponseGeneric(const UPnPSessionToken UPnPToken,const char* ServiceURI,const char* MethodName,const char* Params);" + cl);
            if (ServiceGenerator.ServiceConfiguration.HasFragmentedActions(device))
            {
                cs.Append("int " + pc_methodPrefixDef + "AsyncResponse_START(const UPnPSessionToken UPnPToken, const char* actionName, const char* serviceUrnWithVersion);" + cl);
                cs.Append("int " + pc_methodPrefixDef + "AsyncResponse_DONE(const UPnPSessionToken UPnPToken, const char* actionName);" + cl);
                cs.Append("int " + pc_methodPrefixDef + "AsyncResponse_OUT(const UPnPSessionToken UPnPToken, const char* outArgName, const char* bytes, const int byteLength, enum ILibAsyncSocket_MemoryOwnership bytesMemoryOwnership,const int startArg, const int endArg);" + cl);
            }
            BuildUPnPResponseHeaders(cs, device, serviceNames);
            WS = WS.Replace("//{{{Invocation_Response_Methods}}}", cs.ToString());

            #endregion
            #region Eventing Methods
            cs = new CodeProcessor(new StringBuilder(), this.Language == LANGUAGES.CPP);
            cs.Comment("State Variable Eventing Methods");
            BuildStateVariableHeaders(cs, device, serviceNames);
            WS = WS.Replace("//{{{Eventing_Methods}}}", cs.ToString());
            #endregion
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:67,代码来源:EmbeddedCGenerator.cs

示例10: BuildMainUserCode


//.........这里部分代码省略.........
                                        cs.Append(", wc_" + arg.Name);
                                    }
                                    else
                                    {
                                        cs.Append(", " + arg.Name);
                                    }
                                }
                            }
                        }
                        cs.Append(");" + cl);
                        if (this.SubTarget == SUBTARGETS.PPC2003)
                        {
                            cs.Append("	if (that->m_Text.GetLength() > 16384)" + cl);
                            cs.Append("	{" + cl);
                            cs.Append("		that->m_Text = display;" + cl);
                            cs.Append("	}" + cl);
                            cs.Append("	else" + cl);
                            cs.Append("	{" + cl);
                            cs.Append("		that->m_Text += display;" + cl);
                            cs.Append("	}" + cl);
                            cs.Append("	that->SendMessage(WM_USER_UPDATE);" + cl);
                            foreach (UPnPArgument arg in action.Arguments)
                            {
                                if (arg.Direction == "in" && (arg.RelatedStateVar.GetNetType() == typeof(string) ||
                                    arg.RelatedStateVar.GetNetType() == typeof(System.Uri)))
                                {
                                    cs.Append("	if (wc_" + arg.Name + " != NULL) {free(wc_" + arg.Name + ");}" + cl);
                                }
                            }
                        }
                        #endregion

                        cs.Append(cl);
                        cs.Comment("If you intend to make the response later, you MUST reference count upnptoken with calls to " + this.pc_methodLibPrefix + "WebServer_AddRef()");
                        cs.Comment("and " + this.pc_methodLibPrefix + "WebServer_Release()");
                        cs.Append(cl);
                        cs.Comment("TODO: Place Action Code Here...");
                        cs.Append(cl);

                        cs.Comment(cppobj + pc_methodPrefix + "Response_Error(upnptoken, 404, \"Method Not Implemented\");");

                        if (SConf.Actions_Fragmented.Contains(action) == false)
                        {
                            // Standard Response System Only
                            #region Standard Response
                            cs.Append("  " + cppobj + pc_methodPrefix + "Response_" + serviceNames[service] + "_" + action.Name + "(upnptoken");
                            foreach (UPnPArgument arg in action.Arguments)
                            {
                                if (arg.Direction == "out")
                                {
                                    cs.Append("," + ToSampleValue(arg.RelatedStateVar.GetNetType().ToString()));
                                }
                            }
                            cs.Append(");" + cl);
                            #endregion
                        }
                        else
                        {
                            // Fragmented Response System
                            #region Standard Response, Commented out
                            cs.Append("  /* " + cppobj + pc_methodPrefix + "Response_" + serviceNames[service] + "_" + action.Name + "(upnptoken");
                            foreach (UPnPArgument arg in action.Arguments)
                            {
                                if (arg.Direction == "out")
                                {
                                    cs.Append("," + ToSampleValue(arg.RelatedStateVar.GetNetType().ToString()));
开发者ID:evolution124,项目名称:Developer-Tools-for-UPnP-Technologies,代码行数:67,代码来源:EmbeddedCGenerator.cs

示例11: GenerateEx

        protected bool GenerateEx(UPnPDevice device,DirectoryInfo outputDirectory, Hashtable serviceNames)
        {
            AllServices.Clear();
            AddAllServices(device);
            StreamWriter writer;
            ServiceNames = serviceNames;

            // *** Generate Main Code
            Log("Writing main stack module...");

            foreach (UPnPService service in AllServices)
            {
                string servicename = (string)serviceNames[service];
                string servicexml = new UTF8Encoding().GetString(service.GetSCPDXml());
                Log("Generating service class for " + servicename);
                OpenSource.UPnP.ServiceGenerator.Generate("Dv"+servicename,nspace,outputDirectory.FullName + "\\Dv" + servicename + ".cs",service.ServiceID,service.ServiceURN,servicexml);
            }

            CodeProcessor cs = new CodeProcessor(new StringBuilder(),true);
            StringBuilder cs2;

            cs.Comment("UPnP .NET Framework Device Stack, Device Module");
            cs.Comment(VersionString);
            cs.Append(cl);
            cs.Append("using System;" + cl);
            cs.Append("using OpenSource.UPnP;" + cl);
            cs.Append("using "+nspace+";" + cl);
            cs.Append(cl);
            cs.Append("namespace "+nspace+cl);
            cs.Append("{"+cl);
            cs.Append("	/// <summary>"+cl);
            cs.Append("	/// Summary description for SampleDevice."+cl);
            cs.Append("	/// </summary>"+cl);
            cs.Append("	class SampleDevice"+cl);
            cs.Append("	{"+cl);
            cs.Append(" private UPnPDevice device;" + cl);
            cs.Append(cl);
            cs.Append("	public SampleDevice()"+cl);
            cs.Append("	{"+cl);
            gendevnumber = 0;
            GenerateAddDevice(cs,device);

            cs.Comment("Setting the initial value of evented variables");
            foreach (UPnPService service in AllServices)
            {
                string servicename = (string)ServiceNames[service];
                foreach (UPnPStateVariable variable in service.GetStateVariables())
                {
                    if (variable.SendEvent == true)
                    {
                        cs.Append(servicename + ".Evented_" + variable.Name + " = " + this.ToSampleValue(variable.GetNetType().ToString()) + ";" + cl);
                    }
                }
            }

            cs.Append("	}"+cl);
            cs.Append(cl);

            cs.Append("	public void Start()"+cl);
            cs.Append("	{"+cl);
            cs.Append("		device.StartDevice();"+cl);
            cs.Append("	}"+cl);
            cs.Append(cl);

            cs.Append("	public void Stop()"+cl);
            cs.Append("	{"+cl);
            cs.Append("		device.StopDevice();"+cl);
            cs.Append("	}"+cl);
            cs.Append(cl);

            foreach (UPnPService service in AllServices)
            {
                string servicename = (string)serviceNames[service];

                // Build MethodDelegates
                foreach(UPnPAction action in service.Actions)
                {
                    cs.Append("public ");
                    if (action.HasReturnValue==false)
                    {
                        cs.Append("void ");
                    }
                    else
                    {
                        cs.Append(action.GetRetArg().RelatedStateVar.GetNetType().FullName + " ");
                    }
                    cs.Append(servicename + "_" + action.Name + "(");
                    UPnPArgument[] Args = action.ArgumentList;
                    for(int i=0;i<Args.Length;++i)
                    {
                        UPnPArgument arg = Args[i];
                        if (arg.IsReturnValue==false)
                        {
                            if (arg.Direction=="out")
                            {
                                cs.Append("out ");
                            }
                            if (arg.RelatedStateVar.AllowedStringValues==null)
                            {
                                cs.Append(arg.RelatedStateVar.GetNetType().FullName + " ");
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:DotNetGenerator.cs

示例12: SCPDJunk

        private void SCPDJunk(CodeProcessor cs)
        {
            //			cs.Append("								AddRequest(HTTP, p,&addr, &HTTP_Sink_"+name+", TempService);"+cl);

            cs.Append("								if (SCPDURLLength >= 7 && memcmp(SCPDURL, \"http://\", 6) == 0)"+cl);
            cs.Append("								{"+cl);
            cs.Comment("Explicit");
            cs.Append("									"+pc_methodLibPrefix+"ParseUri(SCPDURL, &IP, &Port, &Path);"+cl);
            cs.Append("									p = "+pc_methodPrefix+"BuildPacket(IP, Port, Path, \"GET\");"+cl);
            cs.Append("									free(Path);"+cl);
            cs.Append("								}"+cl);
            cs.Append("								else"+cl);
            cs.Append("								{"+cl);
            cs.Comment("Relative");
            cs.Append("									"+pc_methodLibPrefix+"ParseUri(BaseURL, &IP, &Port, &Path);"+cl);
            cs.Append("									free(Path);"+cl);
            cs.Append("									if (memcmp(SCPDURL, \"/\", 1)!=0)"+cl);
            cs.Append("									{"+cl);
            cs.Append("										if ((Path = (char*)malloc(SCPDURLLength + 2)) == NULL) ILIBCRITICALEXIT(254);" + cl);
            cs.Append("										memcpy(Path, \"/\", 1);"+cl);
            cs.Append("										memcpy(Path + 1, SCPDURL, SCPDURLLength);"+cl);
            cs.Append("										Path[SCPDURLLength + 1] = '\\0';"+cl);
            cs.Append("										p = "+pc_methodPrefix+"BuildPacket(IP, Port, Path, \"GET\");"+cl);
            cs.Append("										free(Path);"+cl);
            cs.Append("									}"+cl);
            cs.Append("									else"+cl);
            cs.Append("									{"+cl);
            cs.Append("										p = "+pc_methodPrefix+"BuildPacket(IP, Port, SCPDURL, \"GET\");"+cl);
            cs.Append("									}"+cl);
            cs.Append("								}"+cl);
            cs.Append(cl);
            cs.Append("								memset((char *)&addr, 0, sizeof(addr));"+cl);
            cs.Append("								addr.sin_family = AF_INET;"+cl);
            cs.Append("								addr.sin_addr.s_addr = inet_addr(IP);"+cl);
            cs.Append("								addr.sin_port = htons(Port);"+cl);
            cs.Append("								free(IP);"+cl);
        }
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:37,代码来源:CPEmbeddedCGenerator.cs

示例13: BuildEventParser

        private void BuildEventParser(CodeProcessor cs, UPnPService s, string urn, string name)
        {
            bool eventedservice = false;
            foreach(UPnPStateVariable V in s.GetStateVariables())
            {
                if (V.SendEvent) eventedservice = true;
            }

            if (urn.StartsWith("urn:schemas-upnp-org:"))
            {
                // Standard Service
                urn = urn.Substring(urn.LastIndexOf(":")+1);
            }
            else
            {
                // Proprietary Service
                urn = urn.Replace(":","_");
                urn = urn.Replace("-","_");
                urn = urn.Replace(".","_");
            }

            cs.Append("void "+this.pc_methodPrefix+urn+"_EventSink(char* buffer, int bufferlength, struct UPnPService *service)"+cl);
            cs.Append("{"+cl);
            cs.Append("	struct "+this.pc_methodLibPrefix+"XMLNode *xml,*rootXML;"+cl);
            if (eventedservice == true)
            {
                cs.Append("	char *tempString;"+cl);
                cs.Append("	int tempStringLength;"+cl);
            }
            cs.Append("	int flg,flg2;"+cl);
            cs.Append(cl);

            bool placeLong = false;
            bool placeULong = false;
            foreach(UPnPStateVariable V in s.GetStateVariables())
            {
                if (V.SendEvent)
                {
                    cs.Append("	"+ToCType(V.GetNetType().FullName)+" "+V.Name+" = 0;"+cl);
                    if (V.GetNetType()==typeof(byte[]))
                    {
                        cs.Append("	int " + V.Name+"Length;"+cl);
                    }
                    switch(V.GetNetType().FullName)
                    {
                        case "System.SByte":
                        case "System.Int16":
                        case "System.Int32":
                            placeLong = true;
                            break;
                        case "System.Byte":
                        case "System.UInt16":
                        case "System.UInt32":
                            placeULong = true;
                            break;
                    }
                }
            }
            if (placeLong == true) cs.Append(" long TempLong;"+cl);
            if (placeULong == true) cs.Append(" unsigned long TempULong;"+cl);

            cs.Append(cl);
            cs.Comment("Parse SOAP");
            cs.Append("	rootXML = xml = "+this.pc_methodLibPrefix+"ParseXML(buffer, 0, bufferlength);"+cl);
            cs.Append("	"+this.pc_methodLibPrefix+"ProcessXMLNodeList(xml);"+cl);
            cs.Append(cl);

            cs.Append("while(xml != NULL)"+cl);
            cs.Append("{"+cl);
            cs.Append("	if (xml->NameLength == 11 && memcmp(xml->Name, \"propertyset\", 11)==0)"+cl);
            cs.Append("	{"+cl);
            cs.Append("		if (xml->Next->StartTag != 0)"+cl);
            cs.Append("		{"+cl);
            cs.Append("			flg = 0;"+cl);
            cs.Append("			xml = xml->Next;"+cl);
            cs.Append("			while(flg==0)"+cl);
            cs.Append("			{"+cl);
            cs.Append("				if (xml->NameLength == 8 && memcmp(xml->Name, \"property\", 8)==0)"+cl);
            cs.Append("				{"+cl);
            cs.Append("					xml = xml->Next;"+cl);
            cs.Append("					flg2 = 0;"+cl);
            cs.Append("					while(flg2==0)"+cl);
            cs.Append("					{"+cl);

            foreach(UPnPStateVariable V in s.GetStateVariables())
            {
                if (V.SendEvent)
                {
                    cs.Append("					if (xml->NameLength == "+V.Name.Length.ToString()+" && memcmp(xml->Name, \""+V.Name+"\", "+V.Name.Length.ToString()+") == 0)"+cl);
                    cs.Append("					{"+cl);
                    cs.Append("						tempStringLength = "+this.pc_methodLibPrefix+"ReadInnerXML(xml,&tempString);"+cl);

                    if (ToCType(V.GetNetType().FullName)=="char*")
                    {
                        cs.Append("							tempString[tempStringLength] = '\\0';"+cl);
                        cs.Append("							"+V.Name+" = tempString;"+cl);
                    }
                    else
                    {
                        switch(V.GetNetType().FullName)
//.........这里部分代码省略.........
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:101,代码来源:CPEmbeddedCGenerator.cs

示例14: GenerateEx


//.........这里部分代码省略.........
                                cs.Append(",struct "+Arg.RelatedStateVar.ComplexType.Name_LOCAL+" *_"+Arg.Name);
                            }
                        }
                    }
                    cs.Append(")");
                    cs.Append(",void* _user");
                    foreach(UPnPArgument Arg in A.Arguments)
                    {
                        if (Arg.Direction=="in")
                        {
                            if (Arg.RelatedStateVar.ComplexType==null)
                            {
                                //NonComplex
                                cs.Append(", "+ToCType(Arg.RelatedStateVar.GetNetType().FullName)+" ");
                                if (Arg.RelatedStateVar.GetNetType()==typeof(string) && !SConf.Actions_ManualEscape.Contains(A))
                                {
                                    cs.Append("unescaped_");
                                }
                                cs.Append(Arg.Name);
                                if (Arg.RelatedStateVar.GetNetType()==typeof(byte[]))
                                {
                                    cs.Append(", int " + Arg.Name+"Length");
                                }
                            }
                            else
                            {
                                //Complex
                                cs.Append(", struct "+Arg.RelatedStateVar.ComplexType.Name_LOCAL+" *"+Arg.Name);
                            }
                        }
                    }
                    cs.Append(");"+cl);
                }
                bool NeedManualComment = false;
                foreach(UPnPAction A in s.Actions)
                {
                    if (SConf.Actions_ManualEscape.Contains(A))
                    {
                        // Manual Escape
                        NeedManualComment = true;
                        break;
                    }
                }
                if (NeedManualComment)
                {
                    cs.Append(cl);
                    cs.Comment("The string parameters for the following actions MUST be MANUALLY escaped");
                    foreach(UPnPAction A in s.Actions)
                    {
                        if (SConf.Actions_ManualEscape.Contains(A))
                        {
                            // Manual Escape
                            cs.Comment("	void "+pc_methodPrefix+"Invoke_"+name+"_"+A.Name);
                        }
                    }
                    cs.Append(cl);
                }
            }
            WS = WS.Replace("//{{{UPnPInvoke_Methods}}}",cs.ToString());
            #endregion

            #region Complex Types
            cs = new CodeProcessor(new StringBuilder(),this.Language == LANGUAGES.CPP);
            EmbeddedCGenerator.BuildComplexTypeDefinitionsAndHeaders(SL,cs,SequenceTable,ChoiceTable,ref SequenceCounter,ref ChoiceCounter,this.pc_methodPrefix,this.pc_methodLibPrefix);
            WS = WS.Replace("//{{{UPnPComplexTypes}}}",cs.ToString());
            #endregion
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:67,代码来源:CPEmbeddedCGenerator.cs

示例15: GenerateEx


//.........这里部分代码省略.........
                        }
                        nic.Append(");" + cl);

                        //Convert the ReturnValue
                        if (action.HasReturnValue)
                        {
                            nic.Append("                    outParams.add(new BasicNameValuePair(\"" + action.GetRetArg().Name + "\", " + SerializeVariable(action.GetRetArg()) + "));" + cl);
                        }

                        //Output Argument Conversion
                        nic.Append(cl);
                        foreach (UPnPArgument arg in action.Arguments)
                        {
                            if (arg.Direction == "out" && !arg.IsReturnValue)
                            {
                                nic.Append("                    outParams.add(new BasicNameValuePair(\"" + arg.Name + "\", " + SerializeReferenceArgument(arg) + "));" + cl);
                            }
                        }

                        // Error case, when a handler wasn't set
                        nic.Append("                }" + cl);
                        nic.Append("                else" + cl);
                        nic.Append("                {" + cl);
                        nic.Append("                    throw(new UPnPInvokeException(501, \"" + action.Name + " Handler Not Specified\"));" + cl);
                        nic.Append("                }" + cl);
                        nic.Append("            }" + cl);
                        nic.Append("        }" + cl);
                    }
                }
                #endregion

                #region Build the Device Structure
                cs = new CodeProcessor(new StringBuilder(), true);
                cs.Comment("UPnP Java/Android Device Stack, Device Implementationr");
                cs.Comment(VersionString);
                cs.Append(cl);
                cs.Append("package " + nspace + ";" + cl);
                cs.Append(cl);
                cs.Append("import java.util.ArrayList;" + cl);
                cs.Append("import java.util.List;" + cl);
                cs.Append("import java.util.jar.Attributes;" + cl);
                cs.Append("import org.apache.http.message.BasicNameValuePair;" + cl);
                cs.Append(cl);
                cs.Append("import opentools.ILib.RefParameter;" + cl);
                cs.Append("import opentools.upnp.ArgumentDirection;" + cl);
                cs.Append("import opentools.upnp.GenericRemoteInvokeHandler;" + cl);
                cs.Append("import opentools.upnp.UPnPAction;" + cl);
                cs.Append("import opentools.upnp.UPnPArgument;" + cl);
                cs.Append("import opentools.upnp.UPnPDevice;" + cl);
                cs.Append("import opentools.upnp.UPnPInvokeException;" + cl);
                cs.Append("import opentools.upnp.UPnPService;" + cl);
                cs.Append("import opentools.upnp.UPnPStateVariable;" + cl);
                cs.Append(cl);
                cs.Append("public class RootDevice" + dvNum.ToString() + "_" + GetDeviceShortName(device) + cl);
                cs.Append("{" + cl);
                cs.Append("    public UPnPDevice rootDevice;" + cl);
                foreach (UPnPService service in AllServices)
                {
                    string serviceName = (string)ServiceNames[service];
                    cs.Append("    public " + serviceName + "_InvokeHandler " + serviceName + "_InvokeCallback;" + cl);
                }
                cs.Append(cl);

                eDeviceIndex = 0;
                PrivateEmbeddedDeviceDeclaration(device, cs);
开发者ID:amadare,项目名称:DeveloperToolsForUPnP,代码行数:66,代码来源:JavaAndroidGenerator.cs


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