private static CreationFactory CreateCreationFactory(string baseURI, MethodInfo method, Dictionary <string, object> pathParameterValues) { OslcCreationFactory [] creationFactoryAttribute = (OslcCreationFactory [])method.GetCustomAttributes(typeof(OslcCreationFactory), false); string title = creationFactoryAttribute[0].title; string label = creationFactoryAttribute[0].label; string[] resourceShapes = creationFactoryAttribute[0].resourceShapes; string[] resourceTypes = creationFactoryAttribute[0].resourceTypes; string[] usages = creationFactoryAttribute[0].usages; string typeName = method.DeclaringType.Name; //controller names must end with Controller int pos = typeName.IndexOf("Controller"); string controllerName = typeName.Substring(0, pos); string creation = ResolvePathParameters(baseURI, controllerName.ToLower(), pathParameterValues); /* TODO Path methodPathAttribute = method.getAttribute(Path.class); * if (methodPathAttribute != null) { * creation = creation + '/' + methodPathAttribute.value(); * } */ CreationFactory creationFactory = null; creationFactory = new CreationFactory(title, new Uri(creation)); //TODO: Normalize the URI if ((label != null) && (label.Length > 0)) { creationFactory.SetLabel(label); } foreach (string resourceShape in resourceShapes) { creationFactory.AddResourceShape(new Uri(baseURI + "/" + resourceShape)); } foreach (string resourceType in resourceTypes) { creationFactory.AddResourceType(new Uri(resourceType)); } foreach (string usage in usages) { creationFactory.AddUsage(new Uri(usage)); } return(creationFactory); }
public void AddCreationFactory(CreationFactory creationFactory) { creationFactories.Add(creationFactory); }