Пример #1
0
        /// <summary>
        /// This constructor is intended to be used only be the ModelManager.
        /// </summary>
        /// <param name="store">The underlying triple store implementation to be used.</param>
        /// <param name="uri">Uniform Resource Identifier of the model.</param>
        public Model(IStore store, UriRef uri)
        {
            _store = store;

            Uri = uri;

            // Searches for the generic method T GetResource<T>(Uri) and saves a handle
            // for later use within GetResource(Uri, Type);
            foreach (MethodInfo methodInfo in GetType().GetMethods())
            {
                if (methodInfo.Name == "GetResource" && methodInfo.IsGenericMethod)
                {
                    _getResourceMethod = methodInfo; break;
                }
            }
        }
Пример #2
0
        private void Initialize(UriRef uri)
        {
            _model      = null;
            _properties = new Dictionary <Property, HashSet <object> >();
            _mappings   = new Dictionary <string, IPropertyMapping>();

            ResourceCache = new ResourceCache();

            Uri = uri;

            IsNew          = true;
            IsSynchronized = false;

            InitializePropertyMappings();

            // We cannot register the resource with the model, if no model is set.
        }
Пример #3
0
 /// <summary>
 /// Create a new resource with a given Uri.
 /// </summary>
 /// <param name="uri"></param>
 public Resource(UriRef uri)
 {
     Initialize(uri);
 }
Пример #4
0
 /// <summary>
 /// Creates a new resource in the model and its backing RDF store. Provides a resource object of the given type.
 /// </summary>
 /// <param name="t">Type of the resource object. Must be derived from Resource.</param>
 /// <param name="format">The format of the resulting uri.</param>
 /// <param name="transaction">Transaction associated with this action.</param>
 /// <returns>An instance of the given object type wrapping the newly created resource.</returns>
 /// <exception cref="ArgumentException">Throws ArgumentException if a resource with the given URI already exists in the model.</exception>
 public virtual object CreateResource(Type t, string format = "urn:uuid:{0}", ITransaction transaction = null)
 {
     return(CreateResource(UriRef.GetGuid(format), t, transaction));
 }
Пример #5
0
 /// <summary>
 /// Creates a new resource in the model and its backing RDF store. Provides a resource object of the given type.
 /// </summary>
 /// <typeparam name="T">Type of the resource object. Must be derived from Resource.</typeparam>
 /// <param name="format">The format of the resulting uri.</param>
 /// <param name="transaction">Transaction associated with this action.</param>
 /// <returns>An instance of the given object type wrapping the newly created resource.</returns>
 /// <exception cref="ArgumentException">Throws ArgumentException if a resource with the given URI already exists in the model.</exception>
 public virtual T CreateResource <T>(string format = "urn:uuid:{0}", ITransaction transaction = null) where T : Resource
 {
     return(CreateResource(UriRef.GetGuid(format), typeof(T), transaction) as T);
 }
Пример #6
0
 /// <summary>
 /// Constructor taking a UriRef parameter
 /// </summary>
 /// <param name="uri">Uri of the property</param>
 public Property(UriRef uri)  : base(uri)
 {
 }
Пример #7
0
 /// <summary>
 /// Constrctor
 /// </summary>
 public Class(UriRef uri) : base(uri)
 {
 }
Пример #8
0
 /// <summary>
 /// Creates a new resource in the model and its backing RDF store. Provides a resource object of the given type.
 /// </summary>
 /// <param name="t">Type of the resource object. Must be derived from Resource.</param>
 /// <param name="format">The format of the resulting uri.</param>
 /// <param name="transaction">ransaction associated with this action.</param>
 /// <returns>An instance of the given object type wrapping the newly created resource.</returns>
 /// <exception cref="ArgumentException">Throws ArgumentException if a resource with the given URI already exists in the model.</exception>
 public object CreateResource(Type t, string format = "http://semiodesk.com/id/{0}", ITransaction transaction = null)
 {
     return(CreateResource(UriRef.GetGuid(format), t, transaction));
 }
Пример #9
0
 /// <summary>
 /// Creates a new resource in the model and its backing RDF store. Provides a resource object of the given type.
 /// </summary>
 /// <typeparam name="T">Type of the resource object. Must be derived from Resource.</typeparam>
 /// <param name="format">The format of the resulting uri.</param>
 /// <param name="transaction">ransaction associated with this action.</param>
 /// <returns>An instance of the given object type wrapping the newly created resource.</returns>
 /// <exception cref="ArgumentException">Throws ArgumentException if a resource with the given URI already exists in the model.</exception>
 public T CreateResource <T>(string format = "http://semiodesk.com/id/{0}", ITransaction transaction = null) where T : Resource
 {
     return(CreateResource(UriRef.GetGuid(format), typeof(T), transaction) as T);
 }