예제 #1
0
        static void AddShortObjectMethods(ITextBuilder builder, NpcExecutionObject executionObject)
        {
            for (int interfaceIndex = 0; interfaceIndex < executionObject.ancestorNpcInterfaces.Count; interfaceIndex++)
            {
                NpcInterfaceInfo npcInterfaceInfo = executionObject.ancestorNpcInterfaces[interfaceIndex];
                for (int methodIndex = 0; methodIndex < npcInterfaceInfo.npcMethods.Length; methodIndex++)
                {
                    NpcMethodInfo npcMethodInfo = npcInterfaceInfo.npcMethods[methodIndex];
                    builder.AppendAscii(npcMethodInfo.methodName);

                    ParameterInfo[] parameters = npcMethodInfo.parameters;
                    for (UInt16 argIndex = 0; argIndex < npcMethodInfo.parametersLength; argIndex++)
                    {
                        ParameterInfo parameterInfo = parameters[argIndex];
                        builder.AppendAscii(' ');
                        builder.AppendAscii(parameterInfo.ParameterType.SosShortTypeName());
                        builder.AppendAscii(':');
                        builder.AppendAscii(parameterInfo.Name);
                    }

                    builder.AppendAscii(" returns ");
#if WindowsCE
                    builder.AppendAscii(npcMethodInfo.methodInfo.ReturnType.SosTypeName());
#else
                    builder.AppendAscii(npcMethodInfo.methodInfo.ReturnParameter.ParameterType.SosShortTypeName());
#endif
                    builder.AppendAscii("\n");
                }
            }
        }
예제 #2
0
 public void GetParentInterfaces(Type type, List <NpcInterfaceInfo> parentNpcInterfaces, List <NpcInterfaceInfo> ancestorNpcInterfaces)
 {
     Type[] parentInterfaces = type.GetInterfaces();
     if (parentInterfaces != null)
     {
         for (int i = 0; i < parentInterfaces.Length; i++)
         {
             Type      parentInterface       = parentInterfaces[i];
             Attribute npcInterfaceAttribute = Attribute.GetCustomAttribute(parentInterface, typeof(NpcInterface));
             if (npcInterfaceAttribute == null)
             {
                 GetParentInterfaces(parentInterface, parentNpcInterfaces, ancestorNpcInterfaces);
             }
             else
             {
                 NpcInterfaceInfo parentNpcInterface = LookupOrCreate(parentInterface);
                 if (parentNpcInterfaces != null && !parentNpcInterfaces.Contains(parentNpcInterface))
                 {
                     parentNpcInterfaces.Add(parentNpcInterface);
                 }
                 if (!ancestorNpcInterfaces.Contains(parentNpcInterface))
                 {
                     ancestorNpcInterfaces.Add(parentNpcInterface);
                 }
                 // Any more parent interfaces shouldn't be added so null is passed
                 GetParentInterfaces(parentInterface, null, ancestorNpcInterfaces);
             }
         }
     }
 }
예제 #3
0
        static void AddVerboseObjectMethods(ITextBuilder builder, NpcExecutionObject executionObject)
        {
            for (int interfaceIndex = 0; interfaceIndex < executionObject.ancestorNpcInterfaces.Count; interfaceIndex++)
            {
                NpcInterfaceInfo npcInterfaceInfo = executionObject.ancestorNpcInterfaces[interfaceIndex];
                for (int methodIndex = 0; methodIndex < npcInterfaceInfo.npcMethods.Length; methodIndex++)
                {
                    NpcMethodInfo npcMethodInfo = npcInterfaceInfo.npcMethods[methodIndex];
#if WindowsCE
                    builder.AppendAscii(npcMethodInfo.methodInfo.ReturnType.SosTypeName());
#else
                    builder.AppendAscii(npcMethodInfo.methodInfo.ReturnParameter.ParameterType.SosTypeName());
#endif
                    builder.AppendAscii(' ');
                    builder.AppendAscii(npcMethodInfo.methodName);

                    builder.AppendAscii('(');

                    ParameterInfo[] parameters = npcMethodInfo.parameters;
                    for (UInt16 j = 0; j < npcMethodInfo.parametersLength; j++)
                    {
                        ParameterInfo parameterInfo = parameters[j];
                        if (j > 0)
                        {
                            builder.AppendAscii(',');
                        }
                        builder.AppendAscii(parameterInfo.ParameterType.SosTypeName());
                        builder.AppendAscii(' ');
                        builder.AppendAscii(parameterInfo.Name);
                    }
                    builder.AppendAscii(")\n");
                }
            }
        }
예제 #4
0
            public NpcInterfaceInfo LookupOrCreate(Type interfaceType)
            {
                NpcInterfaceInfo info;

                if (typeMap.TryGetValue(interfaceType, out info))
                {
                    return(info);
                }

                info = new NpcInterfaceInfo(interfaceType);
                typeMap.Add(interfaceType, info);

                info.InitializeInterfaces(this);
                return(info);
            }
예제 #5
0
 public void TryAdd(Type type, NpcInterfaceInfo info)
 {
     typeMap[type] = info;
 }
예제 #6
0
        void InterfaceCommandHandler(ITextBuilder responseBuilder)
        {
            //
            // Add Interface Definitions
            //
            foreach (NpcInterfaceInfo interfaceInfo in npcExecutor.Interfaces)
            {
                responseBuilder.AppendAscii(interfaceInfo.name);
                for (int i = 0; i < interfaceInfo.parentNpcInterfaces.Count; i++)
                {
                    NpcInterfaceInfo parentNpcInterface = interfaceInfo.parentNpcInterfaces[i];
                    responseBuilder.AppendAscii(' ');
                    responseBuilder.AppendAscii(parentNpcInterface.name);
                }
                responseBuilder.AppendAscii('\n');

                for (int i = 0; i < interfaceInfo.npcMethods.Length; i++)
                {
                    NpcMethodInfo npcMethodInfo = interfaceInfo.npcMethods[i];
#if WindowsCE
                    responseBuilder.Append(npcMethodInfo.methodInfo.ReturnType.SosTypeName());
#else
                    responseBuilder.AppendAscii(npcMethodInfo.methodInfo.ReturnParameter.ParameterType.SosTypeName());
#endif
                    responseBuilder.AppendAscii(' ');
                    responseBuilder.AppendAscii(npcMethodInfo.methodName);

                    responseBuilder.AppendAscii('(');

                    ParameterInfo[] parameters = npcMethodInfo.parameters;
                    for (UInt16 j = 0; j < npcMethodInfo.parametersLength; j++)
                    {
                        ParameterInfo parameterInfo = parameters[j];
                        if (j > 0)
                        {
                            responseBuilder.AppendAscii(',');
                        }
                        responseBuilder.AppendAscii(parameterInfo.ParameterType.SosTypeName());
                        responseBuilder.AppendAscii(' ');
                        responseBuilder.AppendAscii(parameterInfo.Name);
                    }
                    responseBuilder.AppendAscii(")\n");
                }
                responseBuilder.AppendAscii('\n');
            }
            responseBuilder.AppendAscii('\n'); // Add blank line to end (to mark end of interfaces)

            //
            // Add Object Names and their Interfaces
            //
            foreach (NpcExecutionObject executionObject in npcExecutor.ExecutionObjects)
            {
                responseBuilder.AppendAscii(executionObject.objectName);
                for (int i = 0; i < executionObject.parentNpcInterfaces.Count; i++)
                {
                    NpcInterfaceInfo npcInterface = executionObject.parentNpcInterfaces[i];
                    responseBuilder.AppendAscii(' ');
                    responseBuilder.AppendAscii(npcInterface.name);
                }
                responseBuilder.AppendAscii('\n');
            }
            responseBuilder.AppendAscii('\n'); // Add blank line to end (to mark end of objects
        }
예제 #7
0
        public void GenerateMethodsPage(ITextBuilder htmlBuilder)
        {
            htmlBuilder.AppendAscii("<div class=\"methodgroups\">");

            Int32 tabIndex = 1;

            foreach (NpcExecutionObject executionObject in npcExecutor.ExecutionObjects)
            {
                htmlBuilder.AppendAscii("<div class=\"methods\"><hr/><h2>");
                htmlBuilder.AppendAscii(executionObject.objectName);
                htmlBuilder.AppendAscii("</h2><hr/>");

                for (int interfaceIndex = 0; interfaceIndex < executionObject.ancestorNpcInterfaces.Count; interfaceIndex++)
                {
                    NpcInterfaceInfo interfaceInfo = executionObject.ancestorNpcInterfaces[interfaceIndex];
                    for (int methodIndex = 0; methodIndex < interfaceInfo.npcMethods.Length; methodIndex++)
                    {
                        NpcMethodInfo npcMethodInfo = interfaceInfo.npcMethods[methodIndex];

                        ParameterInfo[] parameters     = npcMethodInfo.parameters;
                        Int32           parameterCount = (parameters == null) ? 0 : parameters.Length;

                        //htmlBuilder.AppendFormat("<form class=\"methodform\" action=\"call/{0}.{1}\" method=\"get\">", executionObject.objectName, npcMethodInfo.methodName);
                        htmlBuilder.AppendAscii("<form class=\"methodform\" action=\"call/");
                        htmlBuilder.AppendAscii(executionObject.objectName);
                        htmlBuilder.AppendAscii(".");
                        htmlBuilder.AppendAscii(npcMethodInfo.methodName);
                        htmlBuilder.AppendAscii("\" method=\"get\">");

                        //htmlBuilder.AppendFormat("<input class=\"executebutton\" type=\"submit\" value=\"Execute\" tabindex=\"{0}\"/>", tabIndex + parameterCount);
                        htmlBuilder.AppendAscii("<input class=\"executebutton\" type=\"submit\" value=\"Execute\" tabindex=\"");
                        htmlBuilder.AppendNumber(tabIndex + parameterCount);
                        htmlBuilder.AppendAscii("\"/>");
#if WindowsCE
                        htmlBuilder.Append(TypeAsHtml(npcMethodInfo.methodInfo.ReturnType));
#else
                        htmlBuilder.AppendAscii(TypeAsHtml(npcMethodInfo.methodInfo.ReturnParameter.ParameterType));
#endif

                        //htmlBuilder.AppendFormat("&nbsp;<font class=\"bold\">{0}</font>(", npcMethodInfo.methodInfo.Name);
                        htmlBuilder.AppendAscii("&nbsp;<font class=\"bold\">");
                        htmlBuilder.AppendAscii(npcMethodInfo.methodInfo.Name);
                        htmlBuilder.AppendAscii("</font>(");
                        if (parameterCount > 0)
                        {
                            htmlBuilder.AppendAscii("<div style=\"padding-left:50px;\"><table class=\"methodtable\">");
                            for (UInt16 j = 0; j < parameterCount; j++)
                            {
                                ParameterInfo parameterInfo = parameters[j];
                                //htmlBuilder.AppendFormat("<tr><td>{0}</td><td>&nbsp;{1}</td><td>&nbsp;=&nbsp;</td><td width=\"100%\"><input style=\"width:100%;\" tabindex=\"{3}\" name=\"{2}\"/></td></tr>",
                                //    TypeAsHtml(parameterInfo.ParameterType), parameterInfo.Name, j, tabIndex++);
                                htmlBuilder.AppendAscii("<tr><td>");
                                htmlBuilder.AppendAscii(TypeAsHtml(parameterInfo.ParameterType));
                                htmlBuilder.AppendAscii("</td><td>&nbsp;");
                                htmlBuilder.AppendAscii(parameterInfo.Name);
                                htmlBuilder.AppendAscii("</td><td>&nbsp;=&nbsp;</td><td width=\"100%\"><input style=\"width:100%;\" tabindex=\"");
                                htmlBuilder.AppendNumber(tabIndex++);
                                htmlBuilder.AppendAscii("\" name=\"");
                                htmlBuilder.AppendNumber(j);
                                htmlBuilder.AppendAscii("\"/></td></tr>");
                            }
                            htmlBuilder.AppendAscii("</table></div>");
                        }
                        htmlBuilder.AppendAscii(")</form>");
                    }
                }
                tabIndex++;
                htmlBuilder.AppendAscii("</div>");
            }

            htmlBuilder.AppendAscii("</div>");

            htmlBuilder.AppendAscii("<div id=\"executeframe\"></div>");
        }